laravel-5.4

Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::header() in RevalidateBackHistory.php

随声附和 提交于 2019-12-11 03:26:51
问题 I have written a middleware so that the user can't go again in log in page after logging in. Which will redirect to the admin panel if already logged in. Here is the code: class RevalidateBackHistory { public function handle($request, Closure $next) { $response = $next($request); return $response->header('Cache-Control','nocache, no-store, max-age=0, must-revalidate') ->header('Pragma','no-cache') ->header('Expires','Fri, 01 Jan 1990 00:00:00 GMT'); } } i have called it inside a controller

Laravel policy always false

别等时光非礼了梦想. 提交于 2019-12-11 03:25:07
问题 I'm trying to allow user to view their own profile in Laravel 5.4. UserPolicy.php public function view(User $authUser, $user) { return true; } registered policy in AuthServiceProvider.php protected $policies = [ App\Task::class => App\Policies\TaskPolicy::class, App\User::class => App\Policies\UserPolicy::class ]; Routes Route::group(['middleware' => 'auth'], function() { Route::resource('user', 'UserController'); } ); Blade template @can ( 'view', $user ) // yes @else // no @endcan

Laravel error handling, get_class vs instanceof

给你一囗甜甜゛ 提交于 2019-12-11 03:21:39
问题 In the following code in app/Exceptions/Handler.php, the first one doesn't work but the second one does. dd(get_class($exception)); outputs "Illuminate\Database\Eloquent\ModelNotFoundException". The first one is similar to the doc. How can I make it work using instanceof ? public function render($request, Exception $exception) { //dd(get_class($exception)); // this does not work. if ($exception instanceof Illuminate\Database\Eloquent\ModelNotFoundException ) { return response()->json(['error'

Event listener in laravel 5.4

佐手、 提交于 2019-12-11 02:46:29
问题 I am using laravel 5.4 for creating my project and i used auth controller for login and register what I need is to get the last login time of user and store it in database when i referred that i came about an idea of creating event listeners and i done it.. login event handling in laravel 5 This is in my EventServiceProvider.php <?php namespace App\Providers; use Illuminate\Support\Facades\Event; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class

Laravel with different session lifetimes

白昼怎懂夜的黑 提交于 2019-12-11 02:12:29
问题 Q: How to create sessions with different lifetimes in Laravel 5? This question is not a duplicate of this question. I do not want to use it for any kind of sign in or register. I simply want to store it for 5mins because the call to fetch this data sits on a different server and takes a while to fetch. The problem is that I have another session that needs to be stored for longer and currently using the global config for this session: /* |--------------------------------- | Session Lifetime |-

Using Laravel 5.4 pusher

荒凉一梦 提交于 2019-12-11 01:35:34
问题 I am having trouble making pusher work . I have followed the documentation but I donot know the problem is.. The console returns null. public function broadcastOn() { return new PrivateChannel('my-channel'); } and here is my js for pusher. <script src="https://js.pusher.com/4.0/pusher.min.js"></script> <script> (function () { // Enable pusher logging - don't include this in production Pusher.logToConsole = true; var pusher = new Pusher('6049410e84e42d918b14', { encrypted: true }); var channel

Laravel 5.4, renaming users table column

谁说我不能喝 提交于 2019-12-11 01:16:09
问题 So today I tried to modify the default auth in my laravel project. First of all: Composer (1.4.2) and Laravel (5.4.27) (meaning also all dependencies) are up to date. I verified this with: composer self-update composer update Then I altered the users table via a migration: Schema::table('users', function (Blueprint $users){ $users->string('login', 16)->unique()->after('id'); $users->string('real_name', 32)->after('email'); }); Schema::table('users', function(Blueprint $users){ $users-

Laravel giving 500 internal error on centos 7 with apache and php 7

你。 提交于 2019-12-11 00:58:43
问题 I am new to centos. I have installed apache and php 7. I have also installed all php extensions required for laravel. I have an laravel app working fine on windows.I have just transferred my code from windows to centos 7.The problem is now it shows 500 internal error in console on every route. I have changed .htaccess code as explained here: https://laravel.com/docs/5.0/configuration#pretty-urls folder rights to storage and bootstrap is set to 777, also enabled mod_rewrite. Also when I

how to edit php settings in Laravel 5.4 to accept large csv file uploads?

China☆狼群 提交于 2019-12-10 20:11:48
问题 I can change max file upload size in php.ini in my local but unable to do the same in Laravel 5.4. I want to upload 4mb csv file. 回答1: You need to configure both your webserver and PHP to allow larger file uploads. For PHP you'll want to configure upload_max_filesize and post_max_size to the size you. E.g.: upload_max_filesize = 5M post_max_size = 8M For NGINX you'll want to configure client_max_body_size, and for Apache you'll want to configure LimitRequestBody. There are also several other

How to define or pass auth guard for broadcast authentication routes instead of default auth guard?

北战南征 提交于 2019-12-10 19:26:15
问题 I am very new to realtime event broadcasting, I have simple laravel-echo-server setup and working with everything. I am unable to set/define authentication against other auth guard it is always checking with user/default guard defined in auth.php I have setup the authentication routes for each guards private channels in routes/channel.php as below per documentation. For auth guard user private channels Broadcast::channel('users.{id}', function ($user, $id) { Log::info(class_basename($user));