PHP code example of cuneytyuksel / laravelcategorizable
1. Go to this page and download the library: Download cuneytyuksel/laravelcategorizable 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/ */
cuneytyuksel / laravelcategorizable example snippets
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use AliBayat\LaravelCategorizable\Categorizable;
class Post extends Model
{
use Categorizable;
}
use App\Models\Post;
use AliBayat\LaravelCategorizable\Category;
// first we create a bunch of categories
// create categories
$backEnd = Category::create(['name' => 'Back End']);
$frontEnd = Category::create(['name' => 'Front End']);
$php = Category::create(['name' => 'PHP']);
// assign "PHP" as a child of "Back End" category
$backEnd->appendNode($php);
// assuming that we have a post instance
$post = Post::first();