Recent Posts on Laravel Create a New Post

Laravel get single value from database

Laravel Get Single Value From Database

Hello Friends In this post I am going to show you how to get single value from database in Laravel 5 <?php namespace App\Http\Controllers; use App\Post; use Illuminate\Http\Request; class PostsController extends Controller public function getPostTitle(){ $post=Post::where(['id'=>1])->first(['title']); return $post->title; }

Read More

Get last inserted id in Laravel 5

Get Last Inserted Id In Laravel 5

In Laravel after saving records with Laravel Eloquent you can get last inserted id by getting id property of the same obj from which you have saved. Example public function saveUser(){ $user =new User(); $user->name="Ravi"; $user->address="New Delhi"; $user->save(); //Getting last inserted id return $user->id; }

Read More