update model in laravel code example
Example 1: laravel soft delete
public function up()
{
Schema::table('users', function(Blueprint $table)
{
$table->softDeletes();
});
}
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends Model {
use SoftDeletes;
protected $dates = ['deleted_at'];
}
Example 2: php artisan make model
php artisan make:model Flight
Example 3: larave Soft Deletes
Schema::table('flights', function (Blueprint $table) {
$table->softDeletes();
});
Example 4: laravel scope
public function apply(Builder $builder, Model $model)
{
$builder->where('age', '>', 200);
}
Example 5: laravel model::query
Model::where()->get();
Model::query()->where()->get();
Model::query();
Example 6: create new record via model in laravel
$userData = array('username' => 'Me', 'email' => 'me@yahoo.com');
User::create($userData);