How to retrieving a single row / column from a table in Laravel 5

We can retrieve single row/column from the database table, you may use the first method. This method will return a single StdClass object.

Let’s create a first method in laravel 5

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use DB;

class PostController extends Controller
{
    public function singlePost()
    {
        $getpost = DB::table('tbl_post')->where('slug', 'laravel')->first();
        echo $user->title;
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *