estudijoanpuig gallery codes

estudijoanpuig gallery codes

cerca segons els teus interesos.

Crear repositori a github i posar-hi el contingut desde HTDOCS

encara que el millor es instal.lar [Github Descktop](https://desktop.github.com/) que fara tota la feina per nosaltres.

git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/estudijoanpuig/estudi.git
git push -u origin master

Instal.lar una versio especifica de laravel en aquest cas la 8 amb WEBPACK-MIX.

Laravel és un marc d'aplicacions web amb una sintaxi expressiva i elegant. Un marc web proporciona una estructura i un punt de partida per crear la vostra aplicació, cosa que us permet centrar-vos a crear alguna cosa sorprenent mentre fem els detalls.

					 
composer create-project laravel/laravel proyecto "8.*"
					

configurar xampp i host virtual

activar les extensions gd intl

  
<VirtualHost *:80> 
   DocumentRoot "C:/xampp/htdocs/"
   ServerName localhost  
</VirtualHost>

<VirtualHost *:80> 
   DocumentRoot "C:/xampp/htdocs/laravel/public/"
   ServerName laravel.test  
</VirtualHost>

<VirtualHost *:80> 
   DocumentRoot "C:/xampp/htdocs/spatie/public/"
   ServerName spatie.test
</VirtualHost>

<VirtualHost *:80> 
   DocumentRoot "C:/xampp/htdocs/eloquent/public/"
   ServerName eloquent.test
</VirtualHost>

 127.0.0.1       localhost
	::1             localhost
	
	
	127.0.0.1       filament_tw.test
	127.0.0.1       backpack_tw.test
	127.0.0.1       voyager_tw.test
	127.0.0.1       boomerang_back.test
CONFIGURAR EXTENSION PHP PER A LARAVEL ====================================== descomentar a la linia 920 del fitxer C:\xampp\php\php.ini extension=gd

array php

array php per cridar les dades de una taula segons la consulta query que hi hagi posat.


					<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "estudi";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM `codes` order by categoria asc";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) { 
?> 

<!-- element que vull repetir -->
<?php echo "$row[nom]";?>

<?php }
} else {
echo "0 results";
}
$conn->close();
?> 		

afegir voyager

Voyager és un paquet d'administració de Laravel que inclou operacions BREAD (CRUD), un gestor de mitjans, un creador de menús i molt més.

composer require tcg/voyager

php artisan voyager:install --with-dummy

php artisan voyager:admin joanpuigbertran@gmail.com --create

format json per al dropdown dels formularis de voyager

format json per al dropdown dels formularis de voyager

{
    "default": "tailwind",
    "options": {
        "tailwind": "tailwind",
        "bootstrap": "bootstrap",
        "uikit": "uikit"
    }
}

routes laravel

al fitxer routes\web.php

/*
|--------------------------------------------------------------------------
| les meves routes 
|--------------------------------------------------------------------------
*/

Route::get('/', function () {
    $persons = DB::table('people')->where('categoria', 'painters')
                                ->orderBy('id', 'desc')
                                ->paginate(20);
    return View::make('welcome')->with('persons', $persons);
});

Route::get('/codis', function () {   
    $objectius = App\Objectiu::all();
    return view('codis', compact('objectius'));
});

Route::get('/tools', function () {   
    $tools = App\Tool::all();
    return view('tools', compact('tools'));
});

Route::get('/laravel', function () {   
    return view('laravel');
});

Route::get('/webs', function () {   
    $webs = App\Web::all();
    return view('webs', compact('webs'));
});

/*
|--------------------------------------------------------------------------
| jetstrream Routes
|--------------------------------------------------------------------------
*/

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified'
])->group(function () {
    Route::get('/dashboard', function () {
        return view('dashboard');
    })->name('dashboard');
	
	Route::get('/dashmodels', function () {
		$persons = DB::table('people')->where('categoria', 'models')
                                ->orderBy('nom', 'desc')
                                ->paginate(20);
        return View::make('dashmodels')->with('persons', $persons);
    })->name('dashmodels');
	
	Route::get('/dashpeople', function () {
        $persons = App\Person::all();
    return view('dashpeople', compact('persons'));
    })->name('dashpeople');
});

/*
|--------------------------------------------------------------------------
| voyager Routes
|--------------------------------------------------------------------------
*/
Route::group(['prefix' => 'admin'], function () {
    Voyager::routes();
});

migration laravel tools

exemple per la creacio de la taula tools ("php artisan make:migration create_tools_table")

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateToolsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('tools', function (Blueprint $table) {
           
            $table->id();
			$table->string('nom');
			$table->string('descripcio');
			$table->text('body');
			$table->string('categoria');
			$table->string('img');
			$table->string('img1');
			$table->string('img2');
			$table->string('web');
			$table->string('youtube');
			$table->string('codi');
			$table->string('slug')->unique();
            $table->timestamps();
        });
       
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('tools');
    }
}

voyager creacio d'una taula

En el panell de control, tools\database\create new table

Inside of your admin panel you can visit Tools->Database and you'll be able to view all your current tables in your database. You may also click on 'Create a New Table' to create a new table in your database. All newly created tables will use the charset defined in your default database connection.

vistes i layouts en laravel (views)

Les vistes a Laravel són la part pública que l'usuari del nostre sistema podrà veure, s'escriuen en HTML juntament amb un motor de plantilles anomenat Blade . Les vistes es troben ubicades a la carpeta resources/views/


1-<!-- Stored in resources/views/layouts/app.blade.php -->
<!-- el codi html del header nav -->
@yield('content')
<!-- el codi html del footer -->


2-<!-- Stored in resources/views/pagina.blade.php -->

@extends('layouts.Appestudi')
@section('title', 'Gal.leria de webs')
@section('content')

<!-- el codi html del contingut -->


@stop

Crear un controlador (Controller)

Per crear un controlador utilitzarem les ordres d' artisan , pel nostre exemple crearem el controlador “AlumnoController”, pots fer servir l'opció –resource , aquest recurs crearà les funcions bàsiques de maneig de les sol·licituds HTTP com a funcions d'index, create, store, show, edit, update i destroy.

php artisan make:controller CodesController --resource

vistes laravel cridar foreach

vistes laravel cridar foreach

@foreach ($persons as $person)
	
	{{$person->categoria}}
	
@endforeach
	

creacio d'un middlewares per a protegir las routes.

El middleware ofereix un mecanisme convenient per inspeccionar i filtrar les sol·licituds HTTP que entren a la vostra aplicació.

Per exemple, Laravel inclou un middleware que verifica que l'usuari de la vostra aplicació està autenticat. Si l'usuari no està autenticat, el programari intermedi redirigirà l'usuari a la pantalla d'inici de sessió de l'aplicació. Tanmateix, si l'usuari s'autentica, el programari intermedi permetrà que la sol·licitud continuï més enllà de l'aplicació.

Es pot escriure programari intermediari addicional per realitzar una varietat de tasques a més de l'autenticació. Per exemple, un middleware de registre pot registrar totes les sol·licituds entrants a la vostra aplicació. Hi ha diversos middleware inclosos al marc de Laravel, inclòs middleware per a l'autenticació i la protecció CSRF. Tots aquests middleware es troben al app/Http/Middlewaredirectori.

php artisan make:middleware EnsureTokenIsValid
<?php
 
namespace App\Http\Middleware;
 
use Closure;
 
class EnsureTokenIsValid
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if ($request->input('token') !== 'my-secret-token') {
            return redirect('home');
        }
 
        return $next($request);
    }
}

creacio d'una consulta query

bases de dades en laravel-Database: query builder

<?php
 
namespace App\Http\Controllers;
 
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
 
class UserController extends Controller
{
    /**
     * Show a list of all of the application's users.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $users = DB::select('select * from users where active = ?', [1]);
 
        return view('user.index', ['users' => $users]);
    }
}

Artisan Console

 

Artisan és la interfície de línia d'ordres inclosa amb Laravel. Artisan existeix a l'arrel de la vostra aplicació com a artisanscript i proporciona una sèrie d'ordres útils que us poden ajudar mentre creeu la vostra aplicació. Per veure una llista de totes les ordres d'Artisan disponibles, podeu utilitzar list

php artisan list

php artisan help migrate

php artisan tinker

enllaços html links

ds

enllaç obrir en finestra nova
<a href="url" target="_blank">titol</a>


link image dimensions
<a href="url web"><img src="url image"  width="150" height="150"></a>

crear model

Generating Model Classes

Per començar, creem un model Eloqüent. Els models normalment viuen al app\Models directori i amplien la Illuminate\Database\Eloquent\Modelclasse. Podeu utilitzar l' make:model ordre Artisan per generar un model nou:

php artisan make:model Flight

php artisan make:model Flight --migration


# Generate a model and a FlightFactory class...
php artisan make:model Flight --factory
php artisan make:model Flight -f
 
# Generate a model and a FlightSeeder class...
php artisan make:model Flight --seed
php artisan make:model Flight -s
 
# Generate a model and a FlightController class...
php artisan make:model Flight --controller
php artisan make:model Flight -c
 
# Generate a model, FlightController resource class, and form request classes...
php artisan make:model Flight --controller --resource --requests
php artisan make:model Flight -crR
 
# Generate a model and a FlightPolicy class...
php artisan make:model Flight --policy
 
# Generate a model and a migration, factory, seeder, and controller...
php artisan make:model Flight -mfsc
 
# Shortcut to generate a model, migration, factory, seeder, policy, controller, and form requests...
php artisan make:model Flight --all
 
# Generate a pivot model...
php artisan make:model Member --pivot

crear un model -mcr

Amb -mcr se crearan tres nous fitxers:

Model migracio i controlador

 php artisan make:model Web -mcr



<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Web extends Model
{
    use HasFactory;
	 protected $fillable = array('nom', 'descripcio', 'categoria', 'css', 'framework', 'url', 'download', 'servidor', 'img');
}

filament estructura per la migracio de Code

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Migration auto-generated by TablePlus 4.10.1(202)
 * @author https://tableplus.com
 * @source https://github.com/TablePlus/tabledump
 */
class CreateCodesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('codes', function (Blueprint $table) {
            $table->integer('id')->unsigned()->autoIncrement();
            $table->string('nom', 255);
            $table->string('categoria', 255);
            $table->string('tags', 255);
            $table->text('descripcio')->nullable()->default(NULL);
            $table->longtext('blockcode');
            $table->string('txt', 255)->nullable()->default(NULL);
            $table->string('youtube', 255)->nullable()->default(NULL);
            $table->string('url', 255)->nullable()->default(NULL);
            $table->timestamp('updated_at')->nullable()->default(NULL);
            $table->timestamp('created_at')->nullable()->default(NULL);
        });
    }
   
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('codes');
    }
}

filament estructura migracio per crear la taula objectius

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Migration auto-generated by TablePlus 4.10.1(202)
 * @author https://tableplus.com
 * @source https://github.com/TablePlus/tabledump
 */
class CreateObjectiusTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('objectius', function (Blueprint $table) {
            $table->integer('id')->unsigned()->autoIncrement();
            $table->string('nom', 255);
            $table->text('descripcio');
            $table->string('status', 255);
            $table->string('urlsolucio', 255)->nullable()->default(NULL);
            $table->timestamp('created_at')->nullable()->default(NULL);
            $table->timestamp('updated_at')->nullable()->default(NULL);
        });
    }
   
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('objectius');
    }
}

filament crear un recurs per la taula objectius

en aquest cas i afegeixo al final de l'ordre cmd --generate. I EL NOM EN SINGULAR.

previament tinc que tenir instal.lat:

composer require doctrine/dbal

php artisan make:filament-resource Objectiu --generate

crear acces directe de storage

php artisan storage:link

migracio per la taula people

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Migration auto-generated by TablePlus 4.10.1(202)
 * @author https://tableplus.com
 * @source https://github.com/TablePlus/tabledump
 */
class CreatePeopleTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('people', function (Blueprint $table) {
            $table->integer('id')->unsigned()->autoIncrement();
            $table->string('nom', 255);
            $table->string('img', 255);
            $table->string('categoria', 255);
            $table->string('vestit', 255)->nullable()->default(NULL);
            $table->string('cabell', 255)->nullable()->default(NULL);
            $table->string('origen', 255)->nullable()->default(NULL);
            $table->string('folder', 255)->nullable()->default(NULL);
            $table->string('ins', 255)->nullable()->default(NULL);
            $table->string('face', 255)->nullable()->default(NULL);
            $table->string('mp3', 255)->nullable()->default(NULL);
            $table->timestamp('created_at')->nullable()->default(NULL);
            $table->timestamp('updated_at')->nullable()->default(NULL);
            $table->string('web', 255)->nullable()->default(NULL);
        });
    }
   
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('people');
    }
}

migracio taula tools

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Migration auto-generated by TablePlus 4.10.1(202)
 * @author https://tableplus.com
 * @source https://github.com/TablePlus/tabledump
 */
class CreateToolsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('tools', function (Blueprint $table) {
            $table->integer('id')->unsigned()->autoIncrement();
            $table->string('nom', 255);
            $table->text('descripcio')->nullable()->default(NULL);
            $table->longtext('body');
            $table->string('categoria', 255);
            $table->string('img', 255);
            $table->string('img1', 255)->nullable()->default(NULL);
            $table->string('img2', 255)->nullable()->default(NULL);
            $table->string('youtube', 255)->nullable()->default(NULL);
            $table->string('codi', 255)->nullable()->default(NULL);
            $table->string('slug', 255)->nullable()->default(NULL);
            $table->timestamp('created_at')->nullable()->default(NULL);
            $table->timestamp('updated_at')->nullable()->default(NULL);
            $table->string('web', 255)->nullable()->default(NULL);
        });
    }
   
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('tools');
    }
}

Pujar laravel a servidor compartit

Fraccionar el projecte: 

1.-Pujar tota la carpeta de local al directori del domini. 

2.-Agafal el directori public i posarlo a public_html.

3.-a public_html posar-hi el fitxer .htaccess. 

//3.-a public_html posar-hi el fitxer .htaccess. s//
RewriteEngine On
RewriteCond %{REQUEST_URI} !^public
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ public/$1 [L]

4.-Afegir al final de  bootstrap/app el següent Codi ...

//4.-Codi de bootstrap/app//

//public_path
$app->bind('path.public',function(){
   return realpath('./../public/'); 
});

5.-Modificar la ruta a index.php.  

filtre gallery uikit cards

He inclos dues variacions: 1.- uk-active que ensenya un determinat filtre.  2.- he tret el filtre a laravel subtituït per link a la seva propia gal.leria.

<ul class="uk-subnav uk-subnav-pill">
					<li data-uk-filter-control=""><a href="#">Show All</a></li>
					<li class="uk-active" data-uk-filter-control=".cap"><a href="#">cap</a></li>
					<li data-uk-filter-control=".github"><a href="#">github</a></li>
					<li data-uk-filter-control=".servidor"><a href="#">servidor</a></li>
					<li ><a href="/laravel">laravel</a></li>
					<li data-uk-filter-control=".llibreries"><a href="#">llibreries</a></li>
					<li data-uk-filter-control=".php"><a href="#">php</a></li>
					<li data-uk-filter-control=".html"><a href="#">html</a></li>
					<li data-uk-filter-control=".css"><a href="#">css</a></li>
					<li data-uk-filter-control=".voyager"><a href="#">voyager</a></li>
					<li data-uk-filter-control=".filament"><a href="#">filament</a></li>
				</ul>

laravel storage link solucio per la fragmentacio del codi a servidor compartit

solucio: eliminar la carpeta storage de public i afegir ruta nova i executarla.
es mostrara una pagina en blanc i el acces directe estara creat.

Route::get('/linkstorage', function () {
    Artisan::call('storage:link');
});

consulta a la ruta

Route::get('/', function()
{
    $builds = DB::table('blogs')->where('frontpage', '1')
                                ->orderBy('id', 'desc')
                                ->paginate(20);
    return View::make('pages/home')->with('builds', $builds);
});

route que porta tots els registes de una taula

Route::get('/people', function () {   
    $persons = App\Person::all();
    return view('people', compact('persons'));
});

fancybox imatge en gallery

<!-- FANCYBOX 4 CSS AL HEAD -->
<link rel="stylesheet"href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@4.0/dist/fancybox.css"/>

<!-- FANCYBOX 4 JS AL FINAL BODY -->
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@4.0/dist/fancybox.umd.js"></script>	

<!-- Imatge en gallery al body -->
<a data-fancybox="gallery" data-src="storage/{{$person->img}}"><img src="storage/{{$person->img}}" /></a>

consultas a la route



Route::get('/people', function () {
    $persons = DB::select("SELECT * FROM `people` WHERE `categoria` IN ('photographers', 'painters', 'influencers', 'music'); ");
    return view('people', compact('persons'));
});



Route::get('/dashboard', function()
{
    $persons = DB::table('people')->where('categoria', 'models')
                                ->orderBy('id', 'desc')
                                ->paginate(20);
    return View::make('dashboard')->with('persons', $persons);
})->name('dashboard');

instalar laravel amb jetstream

Una vegada estigui instal.lat posa-hi el voyager o filament

laravel new project --jet

section cards uikit people

<section class="text-gray-400 bg-gray-900" style="background-image: url('liniesvoyager180.png');background-repeat: no-repeat;" >
<div class="uk-container uk-container-large">

     <div class="uk-grid uk-flex-center uk-padding-medium">
    <h1 class="uk-text-center uk-text-middle text-5xl uk-text-bold text-transparent bg-clip-text bg-gradient-to-r from-green-400 via-blue-500 to-purple-500 title-font mb-6">@yield ('title')</h1>
</div>
	
		<div class="uk-grid uk-flex-center ">
		
						<form id="search-form" action="">
							<div class="uk-inline uk-width-1-1">
								<span class="uk-form-icon uk-form-icon-flip uk-icon" data-uk-icon="icon: search"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" data-svg="search"><circle fill="none" stroke="#000" stroke-width="1.1" cx="9" cy="9" r="7"></circle><path fill="none" stroke="#000" stroke-width="1.1" d="M14,14 L18,18 L14,14 Z"></path></svg></span>
								<input class="uk-input uk-width-1-1 search-fld" type="text" placeholder="Type your search" autofocus="">
								<a hidden="" href="#" class="search-filter" data-uk-filter-control="[data-tags*='']">Search</a>
								<a hidden="" href="#" class="search-filter-all uk-active" data-uk-filter-control="">Search all</a>
								<a hidden="" href="#" class="search-filter-none" data-uk-filter-control="[data-empty='']">Filter none</a>
							</div>
						</form>
		</div>
		
		<!--CARDS WRAPPER-->
		
			
		
				<ul class="uk-subnav uk-subnav-pill">
					<li class="uk-active" data-uk-filter-control=""><a href="#">Show All</a></li>
					<li data-uk-filter-control=".painters"><a href="#">painters</a></li>
					<li data-uk-filter-control=".photographers"><a href="#">photographers</a></li>
					<li data-uk-filter-control=".influencers"><a href="#">influencers</a></li>
					<li data-uk-filter-control=".models"><a href="#">models</a></li>
					<li data-uk-filter-control=".music"><a href="#">music</a></li>
					
				</ul>
				<div class="uk-grid uk-grid-medium uk-child-width-1-2@s uk-child-width-1-3@m uk-child-width-1-4@l  uk-child-width-1-4@xl uk-grid-match js-filter" data-uk-grid="masonry: true" data-uk-sortable="handle: .drag-icon">
				
				
		@foreach ($persons as $person)
					
					<!-- card -->
					<div class="{{$person->categoria}}" data-tags="{{$person->nom}} {{$person->categoria}} ">
						<div class="uk-card uk-card-small uk-card-default">
							
							<div class="uk-card-media">
								<div class="uk-inline-clip uk-transition-toggle" tabindex="0">
									<img data-fancybox="gallery" src="storage/{{$person->img}}" >
									<div class="uk-transition-slide-bottom uk-position-bottom uk-overlay uk-overlay-primary">
										<span data-uk-icon="icon:heart; ratio: 0.8"></span>seguidors:  {{$person->ranking}} 
									</div>
								</div>
								
							</div>
							<div class="uk-card-body">
								<h4 class="uk-margin-small-bottom uk-margin-remove-adjacent uk-text-bold text-transparent bg-clip-text bg-gradient-to-r from-green-400 via-blue-500 to-purple-500">{{$person->nom}}</h4>
								<p class="uk-text-small uk-text-muted">{{$person->categoria}}-{{$person->updated_at}}</p>
							</div>
							<div class="uk-card-footer">
								<div class="uk-grid uk-grid-small uk-grid-divider uk-flex uk-flex-middle" data-uk-grid>
									
									<div class="uk-width-auto uk-text-right">
										<a href="{{$person->folder}}" data-uk-tooltip="title: gallery folder" class="uk-icon-link" data-uk-icon="icon:folder; ratio: 1.2"target="_blank"></a>
										<a href="{{$person->ins}}" data-uk-tooltip="title: Instagram" class="uk-icon-link" data-uk-icon="icon:instagram; ratio: 1.2"target="_blank"></a>
										<a href="{{$person->youtube}}" data-uk-tooltip="title: canal youtube" class="uk-icon-link" data-uk-icon="icon:youtube; ratio: 1.2"target="_blank"></a>
										<a href="{{$person->face}}" data-uk-tooltip="title: facebook" class="uk-icon-link" data-uk-icon="icon:facebook; ratio: 1.2"target="_blank"></a>
										<a href="{{$person->tiktok}}" data-uk-tooltip="title: tiktok" class="uk-icon-link" data-uk-icon="icon:tiktok; ratio: 1.2"target="_blank"></a>
										<a data-fancybox href="{{$person->video}}" data-uk-tooltip="title: veure video" class="uk-icon-link" data-uk-icon="icon:play-circle; ratio: 1.2"target="_blank"></a>
										<a href="{{$person->mp3}}" data-uk-tooltip="title: escoltar musica" class="uk-icon-link" data-uk-icon="icon:soundcloud; ratio: 1.2"target="_blank"></a>
									</div>
									<div class="uk-width-auto uk-text-right">
										<a data-uk-tooltip="title: Drag this card" href="#" class="uk-icon-link drag-icon" data-uk-icon="icon:move; ratio: 1.2"></a>
									</div>
								</div>
							</div>
						</div>
					</div>
					<!-- /card -->
				@endforeach
					
				</div>
			
			</div>
			
		</section>

instal.lar laravel ultima versio + jetstream + voyager

laravel new estudijoanpuig --jet

npm install
npm run build
npm run dev

php artisan migrate

composer require tcg/voyager
php artisan voyager:install --with-dummy
php artisan voyager:admin joanpuigbertran@gmail.com --create

Com crear un component?

Al crear el primer component livewire s'han creat una classe i una vista.

  • app\Http\Livewire\ShowPosts.php
  • resources\viewslivewire\show-posts.blade.php

php artisan make:livewire ShowPosts

meta tags in head

  <meta name="description" content="sale of watercolors">
  <meta name="keywords" content="watercolors, laravel, livewire, Wordpress, painting, estudijoanpuig">
  <meta name="author" content="Joan Puig Bertran">

PersonResource.php

En el panel de control de laravel filament: Per crear la llista i el formulari d'edicio editarem el fixer app\resources\PersonResource.php

<?php

namespace App\Filament\Resources;

use App\Filament\Resources\PersonResource\Pages;
use App\Filament\Resources\PersonResource\RelationManagers;
use App\Models\Person;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\FileUpload;
use Filament\Tables\Columns\ImageColumn;
use Filament\Forms\Components\Select;

class PersonResource extends Resource
{
    protected static ?string $model = Person::class;

    protected static ?string $navigationIcon = 'heroicon-o-collection';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\TextInput::make('nom')
                    ->required()
                    ->maxLength(255),
                Forms\Components\FileUpload::make('img'),
                   
                Forms\Components\Select::make('categoria')
                    ->options([
        'photographers' => 'photographers',
        'painters' => 'painters',
        'influencers' => 'influencers',
		'music' => 'music',
        'models' => 'models',
        'esports' => 'espòrts',
    ]),
                Forms\Components\Select::make('vestit')
                    ->options([
        'vestit' => 'vestit',
        'nu' => 'nu',
        'linguerie' => 'linguerie',		
    ]),
                Forms\Components\Select::make('cabell')
                    ->options([
        'rossa' => 'rossa',
        'morena' => 'morena',
        'pelroja' => 'pelroja',		
    ]),
                Forms\Components\Select::make('origen')
                    ->options([
        'caucasica' => 'caucasica',
        'negra' => 'negra',
        'asiatica' => 'asiatica',
		'catalan' => 'catalan',
        'spanish' => 'spanish',
        'asia' => 'asia',
		'africa' => 'africa',
		'north_america' => 'north_america',
        'south_america' => 'south_america',
        'antarctica' => 'antarctica',
		'europe' => 'europe',
        'australia' => 'australia',
    ]),
                Forms\Components\TextInput::make('folder')
                    ->maxLength(255),
                Forms\Components\TextInput::make('ins')
                    ->maxLength(255),
                Forms\Components\TextInput::make('face')
                    ->maxLength(255),
                Forms\Components\TextInput::make('mp3')
                    ->maxLength(255),
                Forms\Components\TextInput::make('web')
                    ->maxLength(255),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('nom'),
                Tables\Columns\ImageColumn::make('img'),
                Tables\Columns\TextColumn::make('categoria'),
                Tables\Columns\TextColumn::make('vestit'),
                Tables\Columns\TextColumn::make('cabell'),
                Tables\Columns\TextColumn::make('origen'),
                Tables\Columns\TextColumn::make('folder'),
                Tables\Columns\TextColumn::make('ins'),
                Tables\Columns\TextColumn::make('face'),
                Tables\Columns\TextColumn::make('mp3'),
                Tables\Columns\TextColumn::make('created_at')
                    ->dateTime(),
                Tables\Columns\TextColumn::make('updated_at')
                    ->dateTime(),
                Tables\Columns\TextColumn::make('web'),
            ])
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\DeleteBulkAction::make(),
            ]);
    }
    
    public static function getRelations(): array
    {
        return [
            //
        ];
    }
    
    public static function getPages(): array
    {
        return [
            'index' => Pages\ListPeople::route('/'),
            'create' => Pages\CreatePerson::route('/create'),
            'edit' => Pages\EditPerson::route('/{record}/edit'),
        ];
    }    
}

crear un recurs per al model Person

//crear un recurs per al App\Models\Person.php://

php artisan make:filament-resource Person

//aixo creara varis fitxers i directori//

+-- PersonResource.php
+-- PersonResource
|   +-- Pages
|   |   +-- CreatePerson.php
|   |   +-- EditPerson.php
|   |   +-- ListPerson.php

panel filament llistar i editar la taula People: php artisan make:filament-resource Person --generate

1.- primer crearem un model.

2.- Editarem el model afegint els camps a protected $fillable.

3.- editrarem la migracio per crear la taula.

4.- crearem el recurs per llistar i editar els campds d'aquesta taula que podrem veure al panell de control.

5.-Editarem PersonResource.php.

php artisan make:model Person -mcr

//editar app\Models\Person.php//
class Person extends Model
{
    use HasFactory;
	 protected $fillable = array('nom', 'img', 'categoria', 'folder', 'web', 'ins', 'face', 'vestit', 'cabell', 'origen');
}

//editar database\migrations\create-people_table.php//
class Person extends Model
{
    use HasFactory;
	 protected $fillable = array('nom', 'img', 'categoria', 'folder', 'web', 'ins', 'face', 'vestit', 'cabell', 'origen');
}

composer require doctrine/dbal
php artisan make:filament-resource Person --generate

//editar app\Filament\PersonResource.php//

<?php

namespace App\Filament\Resources;

use App\Filament\Resources\PersonResource\Pages;
use App\Filament\Resources\PersonResource\RelationManagers;
use App\Models\Person;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\FileUpload;
use Filament\Tables\Columns\ImageColumn;
use Filament\Forms\Components\Select;

class PersonResource extends Resource
{
    protected static ?string $model = Person::class;

    protected static ?string $navigationIcon = 'heroicon-o-collection';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\TextInput::make('nom')
                    ->required()
                    ->maxLength(255),
                Forms\Components\FileUpload::make('img'),
                   
                Forms\Components\Select::make('categoria')
                    ->options([
        'photographers' => 'photographers',
        'painters' => 'painters',
        'influencers' => 'influencers',
		'music' => 'music',
        'models' => 'models',
        'esports' => 'espòrts',
    ]),
                Forms\Components\Select::make('vestit')
                    ->options([
        'vestit' => 'vestit',
        'nu' => 'nu',
        'linguerie' => 'linguerie',		
    ]),
                Forms\Components\Select::make('cabell')
                    ->options([
        'rossa' => 'rossa',
        'morena' => 'morena',
        'pelroja' => 'pelroja',		
    ]),
                Forms\Components\Select::make('origen')
                    ->options([
        'caucasica' => 'caucasica',
        'negra' => 'negra',
        'asiatica' => 'asiatica',
		'catalan' => 'catalan',
        'spanish' => 'spanish',
        'asia' => 'asia',
		'africa' => 'africa',
		'north_america' => 'north_america',
        'south_america' => 'south_america',
        'antarctica' => 'antarctica',
		'europe' => 'europe',
        'australia' => 'australia',
    ]),
                Forms\Components\TextInput::make('folder')
                    ->maxLength(255),
                Forms\Components\TextInput::make('ins')
                    ->maxLength(255),
                Forms\Components\TextInput::make('face')
                    ->maxLength(255),
                Forms\Components\TextInput::make('mp3')
                    ->maxLength(255),
                Forms\Components\TextInput::make('web')
                    ->maxLength(255),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('nom'),
                Tables\Columns\ImageColumn::make('img'),
                Tables\Columns\TextColumn::make('categoria'),
                Tables\Columns\TextColumn::make('vestit'),
                Tables\Columns\TextColumn::make('cabell'),
                Tables\Columns\TextColumn::make('origen'),
                Tables\Columns\TextColumn::make('folder'),
                Tables\Columns\TextColumn::make('ins'),
                Tables\Columns\TextColumn::make('face'),
                Tables\Columns\TextColumn::make('mp3'),
                Tables\Columns\TextColumn::make('created_at')
                    ->dateTime(),
                Tables\Columns\TextColumn::make('updated_at')
                    ->dateTime(),
                Tables\Columns\TextColumn::make('web'),
            ])
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\DeleteBulkAction::make(),
            ]);
    }
    
    public static function getRelations(): array
    {
        return [
            //
        ];
    }
    
    public static function getPages(): array
    {
        return [
            'index' => Pages\ListPeople::route('/'),
            'create' => Pages\CreatePerson::route('/create'),
            'edit' => Pages\EditPerson::route('/{record}/edit'),
        ];
    }    
}

Instal.lacio de Laravel versio 9 porta VITE.

Aguanta tot el meu web i ha estat un gran descobriment!. Al front theme uikit kick-off amb coses de per aqui i per alla i laravel voyager al back-end, foreach a la base de dades i presentades amb datatables.

composer create-project laravel/laravel:^9.0 example-app

laravel configurar el fitxer .env

Aixi si afegim mes llibreries ja trovarem una base de dades on poder magatzemar informacio.

APP_NAME=example-app
APP_ENV=local
APP_KEY=base64:aO1T7D9Qx+pQ5kjDIXrPcHIflOX2WImlT1U0kqROtCQ=
APP_DEBUG=true
APP_URL=http://example-app.test/

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=example-app
DB_USERNAME=root
DB_PASSWORD=

crear servidor virtual .test

al instal.lar laravel hem posat  APP_URL=http://example-app/

ara obrirem els fitxers i els modificarem per poguer navegar en la nostra aplicacio amb chrome, tambe reiniciarem l'Apache del xammp per cridar els canvis:  

C:\xampp\apache\conf\extra\httpd-vhosts.conf

C:\Windows\System32\drivers\etc

127.0.0.1       example-app.test


<VirtualHost *:80> 
   DocumentRoot "C:/xampp/htdocs/example-app/public/"
   ServerName example-app.test 
</VirtualHost>


instal.lacio filament

Sempre ho farem sobre un projecte laravel.

 
composer require filament/filament:"^2.0"


php artisan make:filament-user

crear el primer recurs

 //Si voleu estalviar temps, Filament pot generar automàticament el formulari i la taula per a vosaltres, a partir de les columnes de la base de dades del vostre model.//

composer require doctrine/dbal

php artisan make:filament-resource Web --generate

web resource per filament amb select e imatges

 <?php

namespace App\Filament\Resources;

use App\Filament\Resources\WebResource\Pages;
use App\Filament\Resources\WebResource\RelationManagers;
use App\Models\Web;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class WebResource extends Resource
{
    protected static ?string $model = Web::class;

    protected static ?string $navigationIcon = 'heroicon-o-collection';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
				Forms\Components\FileUpload::make('img'),
                Forms\Components\TextInput::make('nom')
                    ->required()
                    ->maxLength(255),
                Forms\Components\TextInput::make('descripcio')
                    ->maxLength(255),
                Forms\Components\Select::make('categoria')
                    ->options([
        'multipage' => 'multipage',
        'panel' => 'panel',
        'php' => 'php',
        'html' => 'html',
		'localhost' => 'localhost', 
		]),
                Forms\Components\Select::make('css')
                     ->options([
        'bootstrap' => 'bootstrap',
        'tailwind' => 'tailwind',
        'uikit' => 'uikit',
		]),
                Forms\Components\Select::make('framework')
                   ->options([
        'laravel' => 'laravel',
        'wordpress' => 'wordpress',
        'codeigniter' => 'codeigniter',
		'php' => 'php',
		]),
                Forms\Components\TextInput::make('url')
                    ->required()
                    ->maxLength(255),
                Forms\Components\TextInput::make('download')
                    ->maxLength(255),
                Forms\Components\Select::make('servidor')
                    ->options([
        'localhost' => 'localhost',
        'hostinger' => 'hostinger',
        'github' => 'github',
		'synology' => 'synology',
		]),
               
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
			    Tables\Columns\ImageColumn::make('img'),
                Tables\Columns\TextColumn::make('nom')
				->searchable()
                ->sortable(),
                Tables\Columns\TextColumn::make('descripcio')
				->searchable()
                ->sortable(),
                Tables\Columns\TextColumn::make('categoria')
				->searchable()
                ->sortable(),
                Tables\Columns\TextColumn::make('framework')
				->searchable()
                ->sortable(),
                Tables\Columns\TextColumn::make('url'),
                Tables\Columns\TextColumn::make('download'),
                Tables\Columns\TextColumn::make('servidor')
				->searchable()
                ->sortable(),
                Tables\Columns\TextColumn::make('created_at')
                    ->dateTime(),
                Tables\Columns\TextColumn::make('updated_at')
                    ->dateTime(),
                
            ])
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\DeleteBulkAction::make(),
            ]);
    }
    
    public static function getRelations(): array
    {
        return [
            //
        ];
    }
    
    public static function getPages(): array
    {
        return [
            'index' => Pages\ListWebs::route('/'),
            'create' => Pages\CreateWeb::route('/create'),
            'edit' => Pages\EditWeb::route('/{record}/edit'),
        ];
    }    
}

fancybox iframe o video de imatge o texte

 //iframe per l'embed//
<a href="iframe.html" data-fancybox data-type="iframe">nom</a>

//video amb una imatge o texte si la suprimeixo//
<a data-fancybox="video-gallery" href="/img/video.mp4" data-width="640" data-height="360">
  <img src="/img/video.jpeg" width="200" height="150" />
</a>

consulta dues taules inner join al controlador

 
 1/** app\Http\Controllers\BlogPostsController.php (consulta dues taules unirles per categoria) */

    public function index()
    {
       $blog_posts = blog_posts::select(
                            "blog_posts.title",
							"blog_posts.banner",
							"blog_posts.excerpt",
							"blog_posts.published_at",
                            "blog_categories.name as name"
                        )
                        ->join("blog_categories", "blog_categories.id", "=", "blog_posts.blog_category_id")
                        ->get();
					return view('gallery_posts', compact('blog_posts'));
    }


    
    
 2/** routes/web.php */   
 
 Route::get('/gallery_posts','App\Http\Controllers\BlogPostsController@index');


 
 3/**resources\views\gallery_posts.blade.php */
 
 @foreach ($blog_posts as $blog_post)					
 @endforeach

Create fake Data using Tinker

es tracta de genrar dades de prova en qualsevol taula de la bbdd.

 php artisan tinker


App\Models\User::factory(50)->create();

buidar de dades la columna de una taula

 UPDATE codes SET category_id = null;

consulta sql join

Comprovo a phpmyadmin la seva validesa.

 <?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "backpack_tw";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "select `people`.`id`, `people`.`nom`, `people`.`img`, `people`.`updated_at`, `people`.`web`,`people`.`ins`, `people`.`face`,`people`.`mp3`, 
`categories`.`category_nom` as `ggg` from `people` inner join `categories` on `categories`.`id` = `people`.`category_id`";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) { 
?> 
//element a repetir
storage/<?php echo "$row[img]";?>

<?php }
} else {
echo "0 results";
}
$conn->close();
?> 	

MYSQL buidar i copiar columnes de una taula

 //MYSQL: Buidar les dades de una columna
UPDATE tabla SET cantidad = null;


//MYSQL:copiar les dades de una columna a un altre
UPDATE `la_tabla` SET `columna_destino`=`columna_origen`

slug

 Forms\Components\TextInput::make('nom')
				->required()
				->reactive()
				->afterStateUpdated(function (Closure $set, $state) {
					$set('slug', Str::slug($state));
				}),
                Forms\Components\TextInput::make('slug'),

A instal.lar livewire

En un projecte nou al instal.lar jetstream ja s'instal.la tambe LIVEWIRE.

laravel new nom_projecte --jet

en el cas que ja tinguem nomes laravel:

composer require livewire/livewire


<html>
 <head>
   @livewireStyles
 </head>
 <body>
   @livewireScripts
 </body>
</html>

Style background-color

style="background-color:LightPink;"

Style Background image repeat o no

style="background-image: url('{{ asset('img/background/3.jpg') }}');background-repeat: repeat;"

Tailwind Background Color

class="bg-indigo-500"

Bootstrap Background Color

<div class="p-3 mb-2 bg-primary text-white">.bg-primary</div>


Tailwind Padding

<div class="px-8 ...">px-8</div>
<div class="py-8 ...">py-8</div>
<div class="p-8 ...">p-8</div>

codeigniter 3 fitxer .htaccess

En muchos casos al desarrollar sitios o aplicaciones web es necesario limpiar las URLs para además de una cuestión estética, hacerlo un poco más seguro.

En el caso del framework Codeigniter todas las URLs del sistema tendrán una forma similar a la siguiente…

www.misitio.com/index.php/controlador/metodo

Para dejar nuestro desarrollo con un toque más profesional, simplemente añadimos en la raíz de nuestro sitio un archivo llamado .htaccess con el siguiente contenido y problema resuelto.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]

Además debemos modificar el archivo application/config/config.php reemplazando la línea que dice

$config['index_page'] = 'index.php';

Por esto otro:

$config['index_page'] = '';

Eso es todo, ahora las URLs de nuestra aplicación serán limpias sin ese index.php agregado en medio.

www.misitio.com/controller/metodo

configuracio env to .env codeigniter 4

posar en mode development

127.0.0.1       ci4.test


<VirtualHost *:80>   
    DocumentRoot "C:/xampp/htdocs/ci4/public/"
    ServerName ci4.test  
</VirtualHost>


#--------------------------------------------------------------------
# ENVIRONMENT
#--------------------------------------------------------------------

CI_ENVIRONMENT = development

#--------------------------------------------------------------------
# APP
#--------------------------------------------------------------------

app.baseURL = 'http://ci4.test/'
# If you have trouble with `.`, you could also use `_`.
# app_baseURL = ''
# app.forceGlobalSecureRequests = false
# app.CSPEnabled = false

#--------------------------------------------------------------------
# DATABASE
#--------------------------------------------------------------------

database.default.hostname = localhost
database.default.database = ci4
database.default.username = root
database.default.password = 
database.default.DBDriver = MySQLi
database.default.DBPrefix =database.default.port = 3306

codeigniter cridar CSS i javascript

utilitzat 

<?php echo base_url('url full d'estil o javascript');?>

<link rel="stylesheet" href="<?php echo base_url('assets/copy/style.css');?>">


<script  src="<?php echo base_url('assets/copy/script.js');?>"></script>

wordpress plantilla de pagina

<?php /* Template Name: gallery */
get_header(); 
?>


<?php
get_sidebar();
get_footer();


php includes

<?php include 'header_nav.php';?>


<?php include 'footer.php';?>	

crear la taula CODES a la BBDD amb la migracio i model per administrarla

Amb la instruccio make i el nom del model primera lletra majusculas i en singular, preferiblement el mot en angles.

Posteriorment editar aquests dos fitxers podem agafar TablePlus per a exportar el codi per copiar a la migracio.

php artisan make:model Code -mcr

editar el fitxer que ha creat l'instruccio anterior que es trova a: 

 C:\xampp\htdocs\example-app\database\migrations\2023_05_26_145534_create_codes_table.php

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Migration auto-generated by TablePlus 5.3.8(232)
 * @author https://tableplus.com
 * @source https://github.com/TablePlus/tabledump
 */
class CreateCodesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('codes', function (Blueprint $table) {
            $table->integer('id')->unsigned()->autoIncrement();
            $table->string('nom', 255);
            $table->string('categoria', 255);
            $table->string('tags', 255);
            $table->mediumtext('descripcio')->nullable()->default(NULL);
            $table->longtext('blockcode')->nullable()->default(NULL);
            $table->string('txt', 255)->nullable()->default(NULL);
            $table->string('youtube', 255)->nullable()->default(NULL);
            $table->string('url', 255)->nullable()->default(NULL);
            $table->timestamp('updated_at')->nullable()->default(NULL);
            $table->timestamp('created_at')->nullable()->default(NULL);
        });
    }
   
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('codes');
    }
}

editar el fitxer que ha creat la instruccio anterior a:

C:\xampp\htdocs\example-app\app\Models\Code.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Code extends Model
{
    use HasFactory;
	protected $fillable = array('nom', 'categoria', 'tags', 'descripcio', 'blockcode', 'txt', 'youtube', 'url');
}


php artisan migrate

crear resource code a filament

1.- Crear resource code a filament vol dir generar un formulari al tauler de control,  per mantenir la taula codes i una llista per a veurel's tots. En la instruccio make posarem el nom del model que controla la taula, en singular i per tant majuscula la primera lletra.

2.- Editarem el fitxer creat a C:\xampp\htdocs\lar9tailwind\app\Filament\Resources\CodeResource.php amb el seguent codi.

php artisan make:filament-resource Code


<?php
namespace App\Filament\Resources;
use App\Filament\Resources\CodeResource\Pages;
use App\Filament\Resources\CodeResource\RelationManagers;
use App\Models\Code;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class CodeResource extends Resource
{
    protected static ?string $model = Code::class;

    protected static ?string $navigationIcon = 'heroicon-o-collection';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\TextInput::make('nom')
                    ->required()
                    ->maxLength(255),
                Forms\Components\Select::make('categoria')
                    ->options([  
        'codeigniter' => 'codeigniter',
		'css' => 'css',
		'filament' => 'filament',
		'github' => 'github',
		'html' => 'html',
        'laravel' => 'laravel',
		'jetstream' => 'jetstream',
		'livewire' => 'livewire',
		'llibreries' => 'llibreries',
		'mysql' => 'mysql',
		'php' => 'php',
        'voyager' => 'voyager',
        'servidor' => 'servidor',
		'wordpress' => 'wordpress',
    ]),
                Forms\Components\Select::make('tags')
        ->options([
		'artisan' => 'artisan',
		'bootstrap' => 'bootstrap',
		'codeigniter' => 'codeigniter',
		'controllers' => 'controllers',
        'filament' => 'filament',
		'install' => 'install',
        'middlewares' => 'middlewares',
		'models' => 'models',
		'routes' => 'routes',
		'migrations' => 'migrations',
		'query' => 'query',
        'liveware' => 'liveware',
		'components' => 'components',
		'resources' => 'resources',
        'manteniment' => 'manteniment',
		'tailwind' => 'tailwind',
		'uikit' => 'uikit',
		'views' => 'views',
		'wordpress' => 'wordpress',
		
    ]),            
                Forms\Components\RichEditor::make('descripcio')
                    ->columnSpan('full'),
				Forms\Components\RichEditor::make('blockcode')
					->columnSpan('full'),
					
                Forms\Components\TextInput::make('txt')
                    ->maxLength(255),
                Forms\Components\TextInput::make('youtube')
                    ->maxLength(255),
                Forms\Components\TextInput::make('url')
                    ->maxLength(255),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
				Tables\Columns\TextColumn::make('id')->limit(5)
				->searchable()
                ->sortable(),
                Tables\Columns\TextColumn::make('nom')
				->searchable()
                ->sortable(),
                Tables\Columns\TextColumn::make('categoria')
				->searchable()
                ->sortable(),
                Tables\Columns\TextColumn::make('tags')
				->searchable()
                ->sortable(),
                Tables\Columns\TextColumn::make('descripcio'),
                Tables\Columns\TextColumn::make('blockcode'),
                Tables\Columns\TextColumn::make('txt'),
                Tables\Columns\TextColumn::make('youtube'),
                Tables\Columns\TextColumn::make('url'),
                Tables\Columns\TextColumn::make('updated_at')
                    ->dateTime(),
                Tables\Columns\TextColumn::make('created_at')
                    ->dateTime(),
            ])
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\DeleteBulkAction::make(),
            ]);
    }
    
    public static function getRelations(): array
    {
        return [
            //
        ];
    }
    
    public static function getPages(): array
    {
        return [
            'index' => Pages\ListCodes::route('/'),
            'create' => Pages\CreateCode::route('/create'),
            'edit' => Pages\EditCode::route('/{record}/edit'),
        ];
    }    
}


© 2022 estudijoanpuig.com

Facebook Instagram Twitter GitHub