![]() ![]() |
Info | ![]() |
![]() |
![]() ![]() |
Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2020-05-10 (2 months ago) ![]() | Not yet rated by the users | Total: 45 | All time: 9,861 This week: 241![]() |
Version | License | PHP version | Categories | |||
laravel-relational 1.0 | Custom (specified... | 5 | PHP 5, Language, Design Patterns, Traits |
$category = Category::find(1);
$post = Post::find(1);
// Create/Update Child
$category->attach($post)
// Retrieve Category's Posts
$children = $category->children;
foreach($children as $record){
dump($record->child->record);
}
Install the latest version using Composer:
$ composer require raggitech/laravel-relational
then publish the migration & migrate
$ php artisan vendor:publish --tag=laravel-relational
$ php artisan migrate
// An Example : (Post Model)
// Using hasRelationships in Post Model
...
use RaggiTech\Laravel\Relational\hasRelationships;
class Post extends Model
{
use hasRelationships;
...
<a name="parents" id="parents"></a>
<a name="p_a" id="p_a"></a>
// Object
$post->attachTo($category);
// List of Objects
$post->attachTo($category1, $category2);
// OR
$post->attachTo([$category1, $category2]);
<a name="p_d" id="p_d"></a>
// Object
$post->detachFrom($category);
// List of Objects
$post->detachFrom($category1, $category2);
// OR
$post->detachFrom([$category1, $category2]);
<a name="p_r" id="p_r"></a>
// Single
$parent = $post->parent;
// Multi
$parents = $post->parents;
<a name="children" id="children"></a>
<a name="c_a" id="c_a"></a>
// Object
$category->attach($post);
// List of Objects
$category->attach($post1, $post2);
// OR
$category->attach([$post1, $post2]);
<a name="c_d" id="c_d"></a>
// Object
$category->detach($post);
// List of Objects
$category->detach($post1, $post2);
// OR
$category->detach([$post1, $post2]);
<a name="c_r" id="c_r"></a>
// Single
$child = $category->child;
// Multi
$children = $category->children;
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Doc. | Documentation |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.