YouTube Icon

Code Playground.

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

CFG

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

From the database table, we can retrieve single row / column, you can use the first method. This method returns a single object from StdClass.

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;
    }
}




CFG