1. Go to this page and download the library: Download chargefield/laravel-savable 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/ */
chargefield / laravel-savable example snippets
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Chargefield\Savable\Traits\IsSavable;
class Post extends Model
{
use IsSavable;
}
namespace App\Http\Controllers;
use App\Models\Post;
use Chargefield\Savable\Fields\SlugField;
use Chargefield\Savable\Fields\StringField;
use Illuminate\Http\Request;
class PostController
{
public function store(Request $request)
{
$post = Post::make()->savable($request->all())->columns([
StringField::make('title'),
SlugField::make('slug')->fromField('title'),
StringField::make('body'),
])->save();
}
}
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Chargefield\Savable\Fields\Field;
use Chargefield\Savable\Traits\IsSavable;
use Chargefield\Savable\Fields\JsonField;
use Chargefield\Savable\Fields\SlugField;
use Chargefield\Savable\Fields\FileField;
use Chargefield\Savable\Fields\StringField;
use Chargefield\Savable\Fields\BooleanField;
use Chargefield\Savable\Fields\IntegerField;
use Chargefield\Savable\Fields\DatetimeField;
class Post extends Model
{
use IsSavable;
/**
* @return Field[]
*/
public function savableColumns(): array
{
return [
StringField::make('title')->rules('