Answers for "send data to view page in laravel"

PHP
7

laravel pass view with data

return view("blog", ["posts"=>$posts]);
Or:
return view("blog", compact("posts"));
Posted by: Guest on January-03-2020
0

Pass all data to all pages laravel

namespace App\Providers;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

use Illuminate\Support\Facades\Auth;
use DB;


class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
         View::share('key', 'value');
         Schema::defaultStringLength(191);

        $categories=DB::table('categories')->get();
        View::share('categories',$categories);  

    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
Posted by: Guest on October-22-2020

Code answers related to "send data to view page in laravel"

Browse Popular Code Answers by Language