Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel global scope

protected static function booted()
    {
        self::addGlobalScope('latest', function ($query){
            $query->latest('updated_at');
        });
    }
Comment

laravel without global scope

public function boot()
    {
        parent::boot();

        Route::bind('project', function($id) {
            return AppProject::withoutGlobalScopes()->findOrFail($id);
        });
    }
Comment

laravel without global scopes

Model::withoutGlobalScopes()->get();
Comment

laravel local scope

<?php
 
namespace AppModels;
 
use IlluminateDatabaseEloquentModel;
 
class User extends Model
{
    /**
     * Scope a query to only include popular users.
     *
     * @param  IlluminateDatabaseEloquentBuilder  $query
     * @return IlluminateDatabaseEloquentBuilder
     */
    public function scopePopular($query)
    {
        return $query->where('votes', '>', 100);
    }
 
    /**
     * Scope a query to only include active users.
     *
     * @param  IlluminateDatabaseEloquentBuilder  $query
     * @return void
     */
    public function scopeActive($query)
    {
        $query->where('active', 1);
    }
}
Comment

laravel scope

public function apply(Builder $builder, Model $model)
    {
        $builder->where('age', '>', 200);
    }
Comment

laravel global scope

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

PREVIOUS NEXT
Code Example
Php :: Display the image on the front end from category taxonomy 
Php :: symfony get container static 
Php :: using PDO and PHP = Login.php 
Php :: how to fetch all column values php 
Php :: php serialize() 
Php :: wp plugins action link 
Php :: php week of a date 
Php :: heredoc php 
Php :: php mongodb 
Php :: php switch case array 
Php :: connect another database in wordpress 
Php :: php set title dynamically 
Php :: php rotate image 
Php :: doctrine query builder order by multiple 
Php :: Adding JavaScript to a Specific WordPress Post or Page Using Code in the Footer 
Php :: php clear cache 
Php :: php submit form in new tab 
Php :: comments in php 
Php :: php ical 
Php :: laravel with callback 
Php :: laravel 8 query builder 
Php :: combine 2 columns search query laravel 
Php :: phpserver 
Php :: set php var to html 
Php :: laravel get column field name 
Php :: phpspreadsheet CellProtection 
Php :: calculate percentage of amount in php 
Php :: laravel unique validation on multiple columns 
Php :: session not working php 
Php :: session_start cookie lifetime 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =