1. Go to this page and download the library: Download t-labs-co/laravel-marking 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/ */
use TLabsCo\LaravelMarking\Models\Markable;
class MyModel extends Eloquent
{
use Markable;
}
// Pass in a delimited string:
$model->marking('Coffee,Cake,Fruit');
// Or an array:
$model->marking(['Coffee', 'Cake', 'Fruit']);
$model->marking('Coffee,Cake,Fruit');
$model->unmarking('Fruit');
// $model is now just marked with "Coffee" and "Cake"
$model->demarking();
// $model has no marks anymore
'classifications' => ['general', 'drink', 'food']
// Pass in a delimited string:
$model->marking('Cake,Fruit', classification: 'food');
// Or an array:
$model->marking(['Coffee'], classification: 'drink');
'values_caster' => [
'food' => 'intval', //
],
// Pass in a delimited string:
$model->marking('Fruit', ['value' => 2], classification: 'food');
// Or an array:
$model->marking([['name' => 'Coffee', 'value' => 2]], classification: 'drink');
// Or an array:
$model->marking(['Coffee' => ['value' => 2]], classification: 'drink');
use TLabsCo\LaravelMarking\Models\Markable;
use TLabsCo\LaravelMarking\Models\InteractMarkableValue;
class MyModel extends Eloquent
{
use Markable;
use InteractMarkableValue;
}
// Get values map by classification
$model->getMarkingValuesMap('food'); // ['Cake' => 1, 'Fruit' => 2]
// Sum vallues map by classification
$model->sumMarkingValues('food'); // 3
// Update or Add your mark with value in particular classification
$model->updateMarkingValue('Cake', 5, 'food'); // 'Cake' => 5