$post = Post::first();
$post->title; // Something title
$post->title = "new title"; // new title
$user->getOriginal('title'); // Something title
public function author()
{
return $this->belongsTo(Author::class)->withDefault();
}
public function author()
{
return $this->belongsTo(Author::class)->withDefault([
'name' => 'Someone'
]);
}
// whereRaw
$orders = DB::table('posts')
->whereRaw('COUNT(views) > ?', [200])
->get();
$post = Post::create($attributes);
if($post->wasRecentlyCreated) {
// do something
}
$post = Post::find($id);
$post->views++;
$post->save();
// you can increase using
$post = Post::find($id);
$post->increment('views');
// or you can decrease using
$post = Post::find($id);
$post->decrement('views');