laravel-5.5

Laravel 5.5 API resources for collections (standalone data)

本秂侑毒 提交于 2019-11-30 08:59:03
I was wondering if it is possible to define different data for item resource and collection resource. For collection I only want to send ['id', 'title', 'slug'] but the item resource will contain extra details ['id', 'title', 'slug', 'user', etc.] I want to achieve something like: class PageResource extends Resource { /** * Transform the resource into an array. * * @param \Illuminate\Http\Request * @return array */ public function toArray($request) { return [ 'id' => $this->id, 'title' => $this->title, 'slug' => $this->slug, 'user' => [ 'id' => $this->user->id, 'name' => $this->user->name,

Laravel 5.5 why is exception not thrown by foreign key violation from delete method?

那年仲夏 提交于 2019-11-29 14:57:48
I have two tables in a Postgresql 9.3 database, companies and sites. There is a one-to-many relationship between them with companies on the one side. There is a foreign key constraint that prevents the deletion of a company if sites have been assigned to it. If I attempt to delete the company with the ID 'KSL' using an SQL query directly on the database, I get the expected error: ERROR: update or delete on table "companies" violates foreign key constraint "sites_company_id_fkey" on table "sites" DETAIL: Key (company_id)=(KSL) is still referenced from table "sites". I have defined an artisan

Laravel 5.5 login and register page says:The page has expired due to inactivity.[TokenMismatchException]

不羁岁月 提交于 2019-11-28 09:24:54
I just created a new project of laravel version 5.5 with the laravel installer.And run the command " php artisan make:auth ".The views and controller are generated for the user authentication.And also run " php artisan migrate " to create tables needed in the database.When visiting the login page and register page,filling the form and submit.It shows "The page has expired due to inactivity. Please refresh and try again.".But refreshing the page does nothing help. Seen in the source code,where causes the exception: if ($e instanceof ModelNotFoundException) { $e = new NotFoundHttpException($e-

No Application Encryption Key Has Been Specified

删除回忆录丶 提交于 2019-11-27 16:53:10
I'm new to Laravel and I'm trying to use the Artisan command... php artisan serve It displays... Laravel development server started: http://127.0.0.1:8000 However, it won't automatically launch and when I manually enter http://127.0.0.1:8000 it shows this error: RuntimeException No application encryption key has been specified. Any ideas? I'm using Laravel framework 5.5-dev. From Encryption - Laravel - The PHP Framework For Web Artisans : "Before using Laravel's encrypter, you must set a key option in your config/app.php configuration file. You should use the php artisan key:generate command

No Application Encryption Key Has Been Specified

雨燕双飞 提交于 2019-11-26 18:45:01
问题 I'm new to Laravel and I'm trying to use the Artisan command... php artisan serve It displays... Laravel development server started: http://127.0.0.1:8000 However, it won't automatically launch and when I manually enter http://127.0.0.1:8000 it shows this error: RuntimeException No application encryption key has been specified. Any ideas? I'm using Laravel framework 5.5-dev. 回答1: From Encryption - Laravel - The PHP Framework For Web Artisans: "Before using Laravel's encrypter, you must set a

How to Get Current Route Name?

喜夏-厌秋 提交于 2019-11-26 18:12:36
In Laravel 4 I was able to get the current route name using... Route::currentRouteName() How can I do it in Laravel 5? Try this Route::getCurrentRoute()->getPath(); or \Request::route()->getName() from v5.+ use Illuminate\Support\Facades\Route; $currentPath= Route::getFacadeRoot()->current()->uri(); Laravel 5.3 Route::currentRouteName(); //use Illuminate\Support\Facades\Route; Or if you need the action name Route::getCurrentRoute()->getActionName(); You can find everything about laravel Routes in the Laravel API: http://laravel.com/api/5.0/Illuminate/Routing/Router.html http://laravel.com/api

Laravel 5.5 Error Base table or view already exists: 1050 Table 'users' already exists

半城伤御伤魂 提交于 2019-11-26 17:48:32
问题 Specifications: Laravel Version: 5.5.3 PHP Version: 7.1 Database Driver & Version: MariaDB 10.1.26 Description: C:/Users/user/code/blog/>php artisan migrate [Illuminate\Database\QueryException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create table users (id int unsigned not null aut o_increment primary key, name varchar(255) not null, email varchar(255) not null, password varchar(255) not null, remember_token varchar (100) null, created_at

PHP Parse error: syntax error, unexpected '?' in helpers.php 233

こ雲淡風輕ζ 提交于 2019-11-26 13:49:39
When I create a new Laravel project, the browser displays an error 500. I found this in the log: PHP Parse error: syntax error, unexpected '?' in vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233 the code in 233 is: return app('cache')->get($arguments[0], $arguments[1] ?? null); But as i know, null coalescing operator( ?? ) is supported from PHP 7.0 My PHP Version: PHP 7.1.8-2+ubuntu14.04.1+deb.sury.org+4 (cli) (built: Aug 4 2017 14:34:05) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1

PHP Parse error: syntax error, unexpected '?' in helpers.php 233

♀尐吖头ヾ 提交于 2019-11-26 04:27:09
问题 When I create a new Laravel project, the browser displays an error 500. I found this in the log: PHP Parse error: syntax error, unexpected \'?\' in vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233 the code in 233 is: return app(\'cache\')->get($arguments[0], $arguments[1] ?? null); But as i know, null coalescing operator( ?? ) is supported from PHP 7.0 My PHP Version: PHP 7.1.8-2+ubuntu14.04.1+deb.sury.org+4 (cli) (built: Aug 4 2017 14:34:05) ( NTS ) Copyright (c)

“The page has expired due to inactivity” - Laravel 5.5

有些话、适合烂在心里 提交于 2019-11-26 01:45:28
问题 My register page is showing the form properly with CsrfToken ( {{ csrf_field() }} ) present in the form). Form HTML <form class=\"form-horizontal registration-form\" novalidate method=\"POST\" action=\"{{ route(\'register\') }}\"> {{ csrf_field() }} .... </form> I am using inbuilt authentication for the users. Have not changed anything except the routes and redirects. When I submit the form (just after reloading also), it gives that The page has expired due to inactivity. Please refresh and