“Laravel Local Scope” Kode Jawaban

cara membuat model di laravel

php artisan make:model Flight

Laravel Local Scope

<?php
 
namespace App\Models;
 
use Illuminate\Database\Eloquent\Model;
 
class User extends Model
{
    /**
     * Scope a query to only include popular users.
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopePopular($query)
    {
        return $query->where('votes', '>', 100);
    }
 
    /**
     * Scope a query to only include active users.
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $query
     * @return void
     */
    public function scopeActive($query)
    {
        $query->where('active', 1);
    }
}
DJ Ultimate Disco Party

Laravel Global Scope

protected static function boot()
    {
        parent::boot();
  
        static::addGlobalScope(new ArchiveScope);
    }
santosh khanal

Jawaban yang mirip dengan “Laravel Local Scope”

Pertanyaan yang mirip dengan “Laravel Local Scope”

Lebih banyak jawaban terkait untuk “Laravel Local Scope” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya