laravel-5.2

Laravel session data is lost after click

陌路散爱 提交于 2021-02-08 07:56:38
问题 class FileController extends Controller { public function login() { /* * TODO: Handle via CAS * Hardcoded for demo purposes */ Session::put('isLogged', true); Session::put('index', "123456"); return View::make('login'); } public function user() { if(Session::get('isLogged') == true ) return View::make('user'); } } I have the following code. There is a link on login that goes to the FileControllers@user . On the second page my session data is lost (Session::all() is empty). What could be

Laravel session data is lost after click

我与影子孤独终老i 提交于 2021-02-08 07:55:33
问题 class FileController extends Controller { public function login() { /* * TODO: Handle via CAS * Hardcoded for demo purposes */ Session::put('isLogged', true); Session::put('index', "123456"); return View::make('login'); } public function user() { if(Session::get('isLogged') == true ) return View::make('user'); } } I have the following code. There is a link on login that goes to the FileControllers@user . On the second page my session data is lost (Session::all() is empty). What could be

What are the best practices for creating a “settings” model in Laravel 5?

你离开我真会死。 提交于 2021-02-07 18:15:09
问题 This is my first project using Laravel (I'm starting with 5.2). I'm building a self managed website. There's an admin that should save site settings for using later in the website. Eg: Background color, social networks, carousel with pictures, products, etc. My first try was creating a model "Setting" with: id | key (unique) | value . When I tried to save social networks (to display in the site header), I realized I'd have to save in "value" a json with URL, title, etc... Ugly implementation

How to get array index in validation message Laravel 5.2

人走茶凉 提交于 2021-02-07 08:37:39
问题 These arrays I put into Laravel Validator as arguments: ['item.*' => 'string'] // rules ['item.*.string' => 'Item number (index) is not string'] // messages I want to have index number in validation message. Code above is just for demonstration and does not work. How to do this? 回答1: Try this or use this one 'name' : [ { 'value' : 'raju' } , { 'value' : 'rani'} ] and validate it by 'name.*' or 'name.*.value' => 'required|string|min:5' The message will be 'name.*.required' => 'The :attribute

How to get array index in validation message Laravel 5.2

浪子不回头ぞ 提交于 2021-02-07 08:37:02
问题 These arrays I put into Laravel Validator as arguments: ['item.*' => 'string'] // rules ['item.*.string' => 'Item number (index) is not string'] // messages I want to have index number in validation message. Code above is just for demonstration and does not work. How to do this? 回答1: Try this or use this one 'name' : [ { 'value' : 'raju' } , { 'value' : 'rani'} ] and validate it by 'name.*' or 'name.*.value' => 'required|string|min:5' The message will be 'name.*.required' => 'The :attribute

Extension gd is missing from your system - laravel composer Update

守給你的承諾、 提交于 2021-02-05 14:29:51
问题 I newly install Dompdf in Laravel Project via Composer ( composer require barryvdh/laravel-dompdf ). After enter the Command Terminal Reply Following Errors. Problem 1 - dompdf/dompdf v0.7.0 requires ext-gd * -> the requested PHP extension gd is missing from your system. - barryvdh/laravel-dompdf v0.7.0 requires dompdf/dompdf ^0.7 -> satisfiable by dompdf/dompdf[v0.7.0]. - Installation request for barryvdh/laravel-dompdf ^0.7.0 -> satisfiable by barryvdh/laravel-dompdf[v0.7.0]. To enable

Elasticquent(ElasticSearch) Laravel limit

◇◆丶佛笑我妖孽 提交于 2021-02-05 11:21:27
问题 Hi I'm trying to get all results with elasticSearch query, but it returns only 10 results if $limit value is null. $videos = Video::searchByQuery([ 'match' => [ $field => $request->$field ], ],null,null,null); so how to get all results ? 回答1: That's because the default size for requests is 10 and not passing a length limit to any framework is probably going to set it to the default. You can use from and size with large values though: Though from and size can be set as request parameters, they

Laravel order results by column on polymorphic table

邮差的信 提交于 2021-02-04 21:40:14
问题 Short question Using Laravel's Eloquent models; how do I order a query by a column on a has morphMany polymorphic relationship? Longer question Say I have the given table structure: // table: images + -- + ------------ + -------------- + ----- + ----------- + | id | imageable_id | imageable_type | views | upload_date | + -- + ------------ + -------------- + ----- + ----------- + | 1 | 1 | User | 100 | 2016-16-06 | | 2 | 3 | User | 200 | 2016-16-06 | + -- + ------------ + -------------- + ----

Laravel & Valet: Failed to open stream

天涯浪子 提交于 2021-01-29 07:30:18
问题 I'm trying to setup a Laravel project on Valet. I'm getting this error: Warning: require(/Users/davina/Developer/learn-laravel-graphql/public/../vendor/autoload.php): failed to open stream: No such file or directory in /Users/davina/Developer/learn-laravel-graphql/public/index.php on line 24 Fatal error: require(): Failed opening required '/Users/davina/Developer/learn-laravel-graphql/public/../vendor/autoload.php' (include_path='.:/usr/local/Cellar/php/7.3.1/share/php/pear') in /Users/davina

Laravel 5.2, Maximum function nesting level

烈酒焚心 提交于 2021-01-29 03:06:22
问题 Please, help me to find what is going on. I just set up a basic Laravel project. It's a new fresh Laravel project (5.2.29) This is route.php Route::get('/', 'TestController@index'); This is the test controller class TestController extends Controller { public function index() { return view('home'); } } The home.blade.php is the one that comes with a fresh Laravel installation, the one printing "Laravel 5". When I add the 'web' middleware, as following Route::group(['middleware' => ['web']],