laravel-routing

Assigning one route to multiple user without a package in laravel

回眸只為那壹抹淺笑 提交于 2020-08-02 04:43:31
问题 I have created four user type admin,vendor,employee,customer . In the user migration file I have the following: public function up() { Schema::create('users', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); $table->string('email')->unique(); $table->char('contact',24)->nullable(); $table->string('password'); $table->enum('roles',['admin', 'vendor', 'employee', 'customers']); $table->string('image')->nullable(); $table->timestamps(); }); } I have already

How to use variables in routes in laravel?

眉间皱痕 提交于 2020-03-02 10:18:57
问题 I'm trying to build a application in laravel 5.3 in which I get the variable from request method and then trying to pass that variable in a redirect to the routes. I want to use this variable in my view so that I can be able to display the value of variable. I'm currently doing this: In my controller I'm getting the request like this: public function register(Request $request) { $data = request->only('xyz','abc'); // Do some coding . . $member['xyz'] = $data['xyz']; $member['abc'] = $data[

How to use variables in routes in laravel?

删除回忆录丶 提交于 2020-03-02 10:16:28
问题 I'm trying to build a application in laravel 5.3 in which I get the variable from request method and then trying to pass that variable in a redirect to the routes. I want to use this variable in my view so that I can be able to display the value of variable. I'm currently doing this: In my controller I'm getting the request like this: public function register(Request $request) { $data = request->only('xyz','abc'); // Do some coding . . $member['xyz'] = $data['xyz']; $member['abc'] = $data[

Laravel route redirect without closure for route cache

喜夏-厌秋 提交于 2020-02-28 06:14:24
问题 I have this code on my routes.php file that do a redirect. Though the problem is that whenever I ran php artisan route:cache command, it gives me an error of Unable to prepare route [article/{params}] for serialization. Uses Closure. I know this has something to do with routes not allowing it to be cached if it have a closure. But how could I make a workaround for this redirect? Route::get('article/{params}', function($params) { return Redirect::to($params, 301); }); 回答1: Route caching does

Setting up named routes within a subdomain group in Laravel 5.7

喜夏-厌秋 提交于 2020-02-23 07:10:00
问题 I have been working on a multi-tenant app and I'm trying to set up the routes in sub-domains according to the documentation:https://laravel.com/docs/5.7/routing#route-group-sub-domain-routing In my web.php route file, I have something like this: Route::domain('{account}.example.test')->group(function () { Route::get('/home', 'HomeController@index')->name('home'); }); Right now, the problem is using named routes in blade, but I suppose I may run into the same problem eventually in my

how to use IN operator in laravel query (eleqouent and raw query)?

浪尽此生 提交于 2020-02-07 17:16:34
问题 I need to use the IN operator to get the data from the database. I tried using it as below and got an error: $pr =DB::('select * from prstuff p where p.pid in (select pid from prdrop)'); I am new to Laravel and don't know exactly how to use the operators like IN , so please explain to me how to use it. 回答1: you can set the custom select in DB::raw() like this : DB::select(DB::raw('select * from prstuff p where p.pid in (select pid from prdrop)')); or you can use whereIn() like this: DB::table

how to use IN operator in laravel query (eleqouent and raw query)?

☆樱花仙子☆ 提交于 2020-02-07 17:16:14
问题 I need to use the IN operator to get the data from the database. I tried using it as below and got an error: $pr =DB::('select * from prstuff p where p.pid in (select pid from prdrop)'); I am new to Laravel and don't know exactly how to use the operators like IN , so please explain to me how to use it. 回答1: you can set the custom select in DB::raw() like this : DB::select(DB::raw('select * from prstuff p where p.pid in (select pid from prdrop)')); or you can use whereIn() like this: DB::table

Auth::user() is null in new route

拥有回忆 提交于 2020-01-25 08:22:08
问题 i'm using laravel 6 and have 2 route in my app; index and dashboard. My routes/web is: Auth::routes(); Route::middleware(['auth'])->group(function () { Route::get('/index', 'todoApp\TodoController@index')->name('index'); Route::get('/dashboard', 'todoApp\Dashboard@dashboard')->name('dashboard'); }); i added dashboard route recently. Auth::user() is null when i dump it in dashboard route but doesn't in index. What's the 回答1: Your Controller is instantiated before the middleware stack has ran;

Is it possible to create a second Laravel “api route” with a separate API KEY?

僤鯓⒐⒋嵵緔 提交于 2020-01-21 08:27:28
问题 I'm new to Laravel and I am handed an existing application that is composed of two parts: 1 - An admin backend built on Laravel and uses Vueify 2 - The frontend website built on next.js and uses react components The admin part communicates with Laravel using the "web routes" but also uses the "api routes" as well since the vue components make AJAX requests using those "api routes". I am now tasked with "connecting" the frontend part to the laravel app. The frontend part will be using AJAX as

Is it possible to create a second Laravel “api route” with a separate API KEY?

放肆的年华 提交于 2020-01-21 08:26:07
问题 I'm new to Laravel and I am handed an existing application that is composed of two parts: 1 - An admin backend built on Laravel and uses Vueify 2 - The frontend website built on next.js and uses react components The admin part communicates with Laravel using the "web routes" but also uses the "api routes" as well since the vue components make AJAX requests using those "api routes". I am now tasked with "connecting" the frontend part to the laravel app. The frontend part will be using AJAX as