Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel where() method

<?php

namespace AppHttpControllers;

use AppModelsPost;
use IlluminateHttpRequest;

class PageController extends Controller
{
    //
    public function index(){

        $posts = Post::latest("id")->get();
        return view("index",["posts"=>$posts]);//compact($posts)
    }

    public function detail($slug){
        $post = Post::where("slug",$slug)->firstOrfail();
        return  view('post.detail',compact('post'));
        return $slug;
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: php array remove value if exists 
Php :: get post by taxonomy 
Php :: carbon random future date 
Php :: limit 1 1 in laravel query 
Php :: php object(stdclass) to array 
Php :: tipo de conexiones a la base de datos en php 
Php :: How to fix MySql: index column size too large (Laravel migrate) 
Php :: slp price php 
Php :: composer autoload psr-4 
Php :: artisan mograte particular tabel 
Php :: php date is before 
Php :: route params link laravel 
Php :: laravel collect where not 
Php :: php for loop 
Php :: codeigniter store session data 
Php :: how to update radio button value in database using php 
Php :: Laravel query child from parent whereHas 
Php :: carbon last day of month in timestamp 
Php :: php ziparchive compress folder 
Php :: send password reset link code wp 
Php :: google translate api php 
Php :: interface x trait in php 
Php :: check type in php 
Php :: PHP Numeric String 
Php :: laravel wherehas with condition 
Php :: php abs() 
Php :: php convert to lowercase 
Php :: how to backup laravel project 
Php :: laravel limit foreach 
Php :: laravel redirect back with errors and input 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =