laravel-5.5

Redirecting with sending Datas in laravel

为君一笑 提交于 2019-12-11 04:35:29
问题 I tried following code: if the user's info to login is not correct redirect the user to the loin page again with the a message: if (!$info_is_correct){ $_SESSION['err_msg'] = 'your login info is not correct'; return redirect('http://localhost:8000/user/login'); } this is what I do in the login page(view) to echo the error msg: @isset($_SESSION['err_msg']) <div class="alert alert-danger mt-2" style="font-family:IRANSans;font-size:16px ;"> <p> <strong>خطا !</strong> {{$_SESSION['err_msg']}} <

How to always use withTrashed() for model Binding

不想你离开。 提交于 2019-12-11 03:49:15
问题 In my app, I use soft delete on a lot of object, but I still want to access them in my app, just showing a special message that this item has been deleted and give the opportunity to restore it. Currently I have to do this for all my route parametters in my RouteServiceProvider: /** * Define your route model bindings, pattern filters, etc. * * @return void */ public function boot() { parent::boot(); Route::bind('user', function ($value) { return User::withTrashed()->find($value); }); Route:

laravel: Argument 1 passed to App\Exceptions\CustomException::report() must be an instance of Exception,

允我心安 提交于 2019-12-11 03:47:20
问题 I have created a custom exception class in Laravel 5.2. It works well till laravel 5.4. When Im trying to use the same custom exception class with laravel 5.5 it is throwing following error. Type error: Argument 1 passed to App\Utility\Exceptions\CustomException::report() must be an instance of Exception, none given, called in /var/www/html/bubbles/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php on line 102 {"exception":"[object] (Symfony\\Component\\Debug\\Exception

Laravel 5.5 Permissions - User does not have the right roles

谁都会走 提交于 2019-12-11 02:20:36
问题 I'm trying to find a solution in a use case where the admin user does not have the assigned role. In dashboard view it doesn't render the url for users, while if I directly access the dashboard/users, I get: Spatie \ Permission \ Exceptions \ UnauthorizedException user does not have the right roles app/Http/Kernel.php protected $routeMiddleware = [ .... 'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class, 'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class, ]

Laravel using View Composer in my routes with htmlspecial error

耗尽温柔 提交于 2019-12-11 01:50:47
问题 I was trying to do a query in my routes for the view composer to load all the records and count it and display it in my sidebar for purposes. I think there is no problem with the query since it worked in my shell using the php artisan tinker for testing purposes of the query. But I got this error when I try to do it in my routes and pass it to the menu.blade.php Here is the code in my routes with the view composer function. // Menu View for Microbiologist View::composer('microbiologist

Route::redirect with wildcard in Laravel 5.5+

拜拜、爱过 提交于 2019-12-11 00:45:32
问题 The new Route::redirect introduced in Laravel 5.5 is practical, but does it allow {any} wildcard? Here is what I used to do in Laravel 5.4 Route::get('slug', function () { return redirect('new-slug', 301); }); In Laravel 5.5, I can do the following: Route::redirect('slug', url('new-slug'), 301); Which allows route caching by getting rid of the closure. So far so good , but what if I want to use a wildcard? In Laravel 5.4, I could do: Route::get('slug/{any}', function ($any) { return redirect(

Multi auth use one page login laravel

落爺英雄遲暮 提交于 2019-12-10 23:28:51
问题 I'm new in laravel, but i'm curious about multi auth laravel. I want to make some website which has two rules, customer and seller. But, i want they login use same login form. I try to use php artisan make:auth, but i don't understand how to use it in one controller use LoginController.php , From what i seen from many tutorials, it separated with different login form and controller. Like Customer login form and seller login form. Is it possible to make multi auth using one login form and one

Laravel 5.5 How to add dynamic conditions inside a relationship?

前提是你 提交于 2019-12-10 21:49:19
问题 I have a relation to get the friends created on specific date which is working with a static date parameter public function friends() { return $this->hasMany(Friend::class)->where('created_at','2018-01-31'); } But i need to get it for a dynamic date where the $request variable is unavailable inside a relation. I tried like this which is not working public function friends($request) { return $this->hasMany(Friend::class)->where('created_at',$request->date); } How can i solve this issue? 回答1:

404 error for socket.io on localhost - XAMPP - Laravel 5.5

╄→尐↘猪︶ㄣ 提交于 2019-12-10 20:47:54
问题 I am using XAMPP, Window 8.1 , Laravel 5.5 on localhost I wrote code for broadcasting in laravel using pusher and works fine. As pusher is very costly so, I am planning to move to socket.io Added below link in master blade. <script src="{{ asset('socket.io-client/dist/socket.io.js') }}"></script> Also ran this command in cmd npm install express ioredis socket.io --save but this shows me an error below. If you see the screenshot, the 404 error is for url is http://localhost:1234/socket.io/?EIO

How to generate set array of object in post request in Swagger with Laravel?

左心房为你撑大大i 提交于 2019-12-10 18:38:03
问题 I am trying to generate array of object in Laravel-5.5 Swagger using body request in Laravel Model. How should i achieve desired output ?? [ { "user_name": "string", "education": [ { "degree": [ { "year": "string", "name": "string" }, { "year": "string", "name": "string" } ], "hobby": [ { "type": "string", "description": "string" }, { "type": "string", "description": "string" } ] } ] } ] can anyone please help me ? Thanks. 回答1: In "User" model you just need to put this below code. /** * @SWG