Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Post extends Eloquent {
- /**
- * The database table used by the model.
- *
- * @var string
- */
- protected $table = 'posts';
- protected $softDelete = true;
- ...
- ...->whereNull('deleted_at')->get();
- DB::table('pages')->select('id','title', 'slug')
- ->where('is_navigation','=','yes')
- ->where('parent_id','=',$parent_id)
- ->orderBy('page_order')
- ->get();
- DB::table('pages')->select('id','title', 'slug')
- ->where('is_navigation','=','yes')
- ->where('parent_id','=',$parent_id)
- ->whereNull('deleted_at')
- ->orderBy('page_order')
- ->get();
- $objCars = Car::where("color","blue");
- SELECT
- *
- FROM
- cars
- WHERE
- deleted_at IS NULL
- AND
- "color" = 'blue'
- $objCars = Car::where("color","blue")->orWhere("color","red");
- SELECT
- *
- FROM
- cars
- WHERE
- deleted_at IS NULL
- AND
- "color" = 'blue'
- OR
- "color" = 'red'
- SELECT
- *
- FROM
- cars
- WHERE
- (
- deleted_at IS NULL
- AND
- "color" = 'blue'
- )
- OR
- "color" = 'red'
- $objCars = Car::where(
- function ( $query ) {
- $query->where("color","blue");
- $query->orWhere("color","red");
- }
- );
- SELECT
- *
- FROM
- cars
- WHERE
- deleted_at IS NULL
- AND
- (
- "color" = 'blue'
- OR
- "color" = 'red'
- )
- public function __construct()
- {
- parent::__construct();
- //Rest of my code
- }
- Post::all()
- <?php
- namespace AppModels;
- use IlluminateDatabaseEloquentModel;
- use IlluminateDatabaseEloquentSoftDeletes;
- class Banners extends Model
- {
- use SoftDeletes;
- //no need of this below line
- //protected $softDelete = true;
- }
Add Comment
Please, Sign In to add comment