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

Leave a Reply

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