Laravel eloquent

Ejemplos de código

8
0

laravel rellenable

    /**
     * The attributes that are mass assignable.
     */
    protected $fillable = [
      					   'title',
                           'slug',
                           'body',
                           'image',
                           'published',
                           'comments_open'
                          ];
5
0

laravel borrar donde

DB::table('users')->where('id', $id)->delete();
4
0

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
3
0

laravel findorfail

$model = App\Flight::where('name', 'Mike')->firstOrFail();
3
0

laravel donde tiene

use Illuminate\Database\Eloquent\Builder;

// Retrieve posts with at least one comment containing words like foo%...
$posts = App\Post::whereHas('comments', function (Builder $query) {
    $query->where('content', 'like', 'foo%');
})->get();

// Retrieve posts with at least ten comments containing words like foo%...
$posts = App\Post::whereHas('comments', function (Builder $query) {
    $query->where('content', 'like', 'foo%');
}, '>=', 10)->get();
3
0

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
2
0

larave Soft Elimina

Schema::table('flights', function (Blueprint $table) {
    $table->softDeletes();
});
2
0

laravel firstorcreate

// Retrieve flight by name, or create it if it doesn't exist...
$flight = App\Flight::firstOrCreate(['name' => 'Flight 10']);

// Retrieve flight by name, or create it with the name, delayed, and arrival_time attributes...
$flight = App\Flight::firstOrCreate(
    ['name' => 'Flight 10'],
    ['delayed' => 1, 'arrival_time' => '11:30']
);

// Retrieve by name, or instantiate...
$flight = App\Flight::firstOrNew(['name' => 'Flight 10']);

// Retrieve by name, or instantiate with the name, delayed, and arrival_time attributes...
$flight = App\Flight::firstOrNew(
    ['name' => 'Flight 10'],
    ['delayed' => 1, 'arrival_time' => '11:30']
);
1
0

cómo crear un modelo en laravel

php artisan make:model Flight
1
0

actualizar consulta en laravel eloquent

$data = DB::table('cart')
                ->where('crt_id', $id)
               ->update(['crt_status' =>'0']);
1
0

buscar o fallar laravel

$model = App\Models\Flight::findOrFail(1);

$model = App\Models\Flight::where('legs', '>', 100)->firstOrFail();
0
0

cómo crear un modelo en laravel

php artisan make:model Flight
0
0

propiedad de laravel

// Create a new user in the database...
$user = User::create(array('name' => 'John'));

// Retrieve the user by the attributes, or create it if it doesn't exist...
$user = User::firstOrCreate(array('name' => 'John'));

// Retrieve the user by the attributes, or instantiate a new instance...ddd
$user = User::firstOrNew(array('name' => 'John'));

En otros idiomas

Esta página está en otros idiomas

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................