PHP code example of morningtrain / laravel-fields

1. Go to this page and download the library: Download morningtrain/laravel-fields 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/ */

    

morningtrain / laravel-fields example snippets


$field->update($model, $request, FieldContract::BEFORE_SAVE);

$field->update($model, $request, FieldContract::AFTER_SAVE);

$request = request();

if (is_array($fields) && !empty($fields)) {

    foreach ($fields as $field) {
        $field->update($model, $request, FieldContract::BEFORE_SAVE);
    }

    $model->save();

    foreach ($fields as $field) {
        $field->update($model, $request, FieldContract::AFTER_SAVE);
    }

}

use Illuminate\Database\Eloquent\Model;
use MorningTrain\Laravel\Fields\Contracts\FieldContract;

Field::create('name_of_attribute')

Field::hidden('name_of_attribute', 'value to apply')

Field::belongsToMany('name_in_request')
    ->relation('name_of_relation')
    ->removeMissing()