laravel rellenable
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'title',
'slug',
'body',
'image',
'published',
'comments_open'
];
laravel rellenables
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'title',
'slug',
'body',
'image',
'published',
'comments_open'
];
laravel borrar donde
DB::table('users')->where('id', $id)->delete();
laravel crear el modelo
# The easiest way to create a model instance is using the
# make:model Artisan command:
php artisan make:model Flight
# If you would like to generate a database migration when you
# generate the model, you may use the --migration or -m option:
php artisan make:model Flight --migration
php artisan make:model Flight -m
laravel crear modelo
# The easiest way to create a model instance is using the
# make:model Artisan command:
php artisan make:model Flight
# If you would like to generate a database migration when you
# generate the model, you may use the --migration or -m option:
php artisan make:model Flight --migration
php artisan make:model Flight -m
ámbito de aplicación de la muestra laravel 8
// in your model
public function scopeField($query)
{
return $query->where('field', 'value'); // if in header return $query->where('field', request()->field);
}
// in your controller or repository
public function index()
{
return Package::field()->get();
}
cómo crear un modelo en laravel
php artisan make:model Flight
laravel relación de alcance
class User extends Model {
public function scopePopular($query)
{
return $query->where('votes', '>', 100);
}
public function scopeWomen($query)
{
return $query->whereGender('W');
}
}
alcance de laravel
public function apply(Builder $builder, Model $model)
{
$builder->where('age', '>', 200);
}
laravel alcance
public function apply(Builder $builder, Model $model)
{
$builder->where('age', '>', 200);
}