1. Go to this page and download the library: Download lordjoo/crudi library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lordjoo / crudi example snippets
artisan vendor:publish
artisan migrate
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Lordjoo\Crudi\Traits\CrudiControllerTrait;
class PostController extends Controller
{
use CrudiControllerTrait;
}
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Lordjoo\Crudi\Models\CrudiModel;
class Post extends CrudiModel
{
use HasFactory;
}
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Lordjoo\Crudi\Models\CrudiModel;
class Post extends CrudiModel
{
use HasFactory;
/*
* System use this object to create the form for creating and updating the model
* Types available :
* - text
* - file
* - textarea
* - relation_select
*/
protected $fields = [
[
'type'=>"text",
'name'=>"Title",
'col'=>'name',
],
[
'type'=>"textarea",
'name'=>"Body",
'col'=>'body'
],
[
'type'=>"image",
"accept"=>"img",
'name'=>"Post Thumbnail",
'col'=>'img_id'
],
[
'type'=>'relation_select',
"name"=>"Category",
'col'=>"category_id",
"relation" => "category"
],
];
}
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Lordjoo\Crudi\Models\CrudiModel;
class Post extends CrudiModel
{
use HasFactory;
protected $dataTable = [
[
'data'=>'id',"title"=>"ID"
],
[
'data'=>"name",'title'=>"Post Title","width"=>200
],
[
'data'=>"thumbnail_url",'title'=>"Post Photo","render"=>'`<img src="${data}" />`'
],
[
'data'=>'id','title'=>"Category",'name'=>'category','custom'=>true,"width"=>200
]
];
protected $datatables_custom = [
[
'col'=>"Category",
"relation"=>"category",
"relation_col"=>'name'
]
];
protected $with = ['category'];
public function category(){
return $this->belongsTo(Category::class);
}
}
bash
php artisan make:model Post -mc
PostController.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.