Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel casts pivot table

<?php
 
namespace AppModels;
 
use IlluminateDatabaseEloquentModel;
 
class Role extends Model
{
    /**
     * The users that belong to the role.
     */
    public function users()
    {
        return $this->belongsToMany(User::class)->using(RoleUser::class);
    }
}
/**
*When defining the RoleUser model, you should extend the 
IlluminateDatabaseEloquentRelationsPivot
*/
<?php
 
namespace AppModels;
 
use IlluminateDatabaseEloquentRelationsPivot;
 
class RoleUser extends Pivot
{
    //
}
Comment

PREVIOUS NEXT
Code Example
Php :: check url parameter if not redirect wordpress 
Php :: simple bindings laravel 
Php :: docker php-fpm-apline add imagick 
Php :: Laravel unique Validation with multiple column 
Php :: octobercms mail 
Php :: Add current year on WordPress using Shortcode 
Php :: php function to get the last value of array 
Php :: where to add browscap php 
Php :: how to define a function in scheme 
Php :: update php local 
Php :: pass the product name to form field cf7 woocommerce 
Php :: drupal form show description 
Php :: encapsulation in php 
Php :: how to get today week month ad year data in eloquent 
Php :: laravel update method 
Php :: phph call functions from other .php file 
Php :: Passing values to blade using redirect() and back() functions 
Php :: confirm popup laravel 
Php :: php iframe add content 
Php :: numbers not displaying in laravel pagination 
Php :: get id from object 
Php :: Declare A PHP Array 
Php :: test_input php 
Php :: php/Laravel check if date is passed 
Php :: array filter php get first object 
Php :: laravel set env to production 
Php :: public $baseURL codeigniter 4 
Php :: laravel route namespace 
Php :: codeigniter crud generator 
Php :: laravel empty 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =