1. Go to this page and download the library: Download zerochip/laravel-lineage 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/ */
zerochip / laravel-lineage example snippets
'providers' => [
// Other Service Providers
Zerochip\LineageServiceProvider::class,
];
namespace App;
use Illuminate\Database\Eloquent\Model;
use Zerochip\Lineage\LineageTrait
class Subject extends Model
{
use LineageTrait;
}
$subject = Subject::find(1);
$quizzes = [];
foreach ($subject->courses as $course) {
foreach ($course->chapters as $chapter) {
foreach($chapter->topics as $topic) {
foreach($topic->sections as $section) {
$quizzes = $quizzes->merge($section->quizzes);
}
}
}
}
$subject->lineage('course->chapters');
// the following won't work
$subject->lineage(course->chapters);
$subject->lineage('course->chapters');
// the following will cause an error
$subject->lineage('course');
$subject->lineage('course->chapters');
// produces the same result as above
$subject->lineage('->course->chapters');
$subject->lineage('course->chapters');
// the following will cause an error
$subject->lineage('course->chapters->');
use Zerochip\Lineage;
$subject = Subject::find(1);
$topics = Lineage::get($subject, 'course->chapters->topics');
// The same with a collection
$courses = Courses::get();
$sections = Lineage::get($courses, 'chapters->topics->sections');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.