laravel-5.4

Laravel middleware with multiple roles

百般思念 提交于 2019-11-28 18:28:25
I've been running into some issues with Laravel's middleware. Let me tell you the basic idea of what I'm trying to accomplish: Registered users on the site will have one of four roles: Student (default): can access ' index ' and ' show ' views Approver: can access previous, plus ' overview ', ' update ' Editor: can access previous, plus ' create ', ' edit ' and ' store ' Admin: can access everything fyi: 'overview' is sort of an index view, but only for approver role and higher What would you guys suggest is the best way to go about doing this? This is what I've done so far, but it doesn't

Laravel 5.4 Disable Register Route

随声附和 提交于 2019-11-28 17:28:25
I am trying to disable the register route on my application which is running in Laravel 5.4. In my routes file, I have only the Auth::routes(); Is there any way to disable the register routes? The code : Auth::routes(); its a shorcut for this collection of routes: // Authentication Routes... Route::get('login', 'Auth\LoginController@showLoginForm')->name('login'); Route::post('login', 'Auth\LoginController@login'); Route::post('logout', 'Auth\LoginController@logout')->name('logout'); // Registration Routes... Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name(

How to integrate Facebook PHP SDK with Laravel 5.4?

跟風遠走 提交于 2019-11-28 16:07:32
I was searching for an easy way to integrate Facebook PHP SDK with Laravel 5.4. Essentially, I wanted to make it available as a service within my Laravel app. Of course there is SammyK/LaravelFacebookSdk on github. But for some reason I didn't want to use it. I felt the setup was adding another layer that I would have to understand, and work within the constraints. There is also Laravel's own Socialite package. But this is essentially for simple authentication only. If I want to upload photos, comments, make batch requests, these are not possible. Socialite does not use Facebook's PHP SDK as a

Laravel 5.4 create model, controller and migration in single artisan command

梦想与她 提交于 2019-11-28 13:20:01
问题 I can create a model and resource controller (binded to model) with the following command php artisan make:controller TodoController --resource --model=Todo I want to also create a migration with the above command, is it possible? 回答1: You can do it if you start from the model php artisan make:model Todo -mcr if you run php artisan make:model --help you can see all the available options -m, --migration Create a new migration file for the model. -c, --controller Create a new controller for the

mariaDB JSON support in Laravel

独自空忆成欢 提交于 2019-11-28 12:22:50
I'm trying to create a json database in XAMP, while using the phpmyAdmin it showed me that I'm using mariaDB but in my xamp-control panel v3.2.2 it shows running mySQL on port 3306 . I'm using Laravel 5.4 framework to create the database, following is my migration which I'm trying to execute: Schema::connection('newPortal')->create('pages', function (Blueprint $table){ $table->increments('id'); $table->string('title'); $table->string('slug')->unique()->index(); $table->json('styles')->nullable(); $table->json('content')->nullable(); $table->json('scripts')->nullable(); $table->softDeletes();

No hint path defined for [mail] Laravel 5.4

≡放荡痞女 提交于 2019-11-28 11:52:28
hi guys i'm trying to show my markdown email on view, but there's something wrong on my mail view, it shows like ErrorException in FileViewFinder.php line 112: No hint path defined for [mail]. (View: /opt/lampp/htdocs/ppsb_new/core/resources/views/emails/tagihan.blade.php) and my markdown mail view @component('mail::message') # TAGIHAN PEMBAYARAN Berikut tagihan anda untuk pembayaran @component('mail::button', ['url' => '']) wut ? @endcomponent Gunakan kode tagihan tersebut untuk membayar tagihan. Thanks,<br> {{ config('app.name') }} @endcomponent and there's also vendor on my views who have

Laravel: left join query

∥☆過路亽.° 提交于 2019-11-28 11:34:38
问题 I have such SQL query, which works fine: SELECT A.program_id FROM A LEFT JOIN B ON A.program_id = B.program_id WHERE B.program_id IS NULL But i want it to rewrite into LARAVEL style, like this: \DB::table('A') ->join('B', 'A.program_id', '=', 'B.program_id') ->select('A.program_id') ->whereNull('B.program_id') ->get()->toArray(); But this code returns me 0 results. 回答1: You are using join instead of left join Try this \DB::table('A') ->leftjoin('B', 'A.program_id', '=', 'B.program_id') -

How to upload files in Laravel directly into public folder?

故事扮演 提交于 2019-11-28 10:55:29
The server which I'm hosting my website does not support links so I cannot run the php artisan storage:link to link my storage directory into the public directory. I tried to remake the disk configuration in the filesystems.php to directly reference the public folder but it didn't seems to work either. Is there a way to upload a file using Laravel libraries directly into the public folder or will I have to use a php method? Thanks in advance. sunomad You can create a new storage disc in config/filesystems.php : 'public_uploads' => [ 'driver' => 'local', 'root' => public_path() . '/uploads', ],

How to make Laravel work with Redis cluster on AWS

*爱你&永不变心* 提交于 2019-11-28 10:34:48
问题 I'm trying to use Laravel (5.4) with a clustered version of Redis. I followed the instructions form this post like so: /* |-------------------------------------------------------------------------- | Redis Databases |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also | provides a richer set of commands than a typical key-value systems | such as APC or Memcached. Laravel makes it easy to dig right

Laravel 5.4 - Validation with Regex [duplicate]

China☆狼群 提交于 2019-11-28 07:22:37
This question already has an answer here: Issue with Laravel Rules & Regex (OR) operator 2 answers Below is my rule for project name: $this->validate(request(), [ 'projectName' => 'required|regex:/(^([a-zA-z]+)(\d+)?$)/u', ]; I am trying to add the rule such that it must start with a letter from a-z or A-z and can end with numbers but most not. Valid values for project name: myproject123 myproject MyProject Invalid values for project name: 123myproject !myproject myproject 123 my project my project123 I tried my regex online: https://regex101.com/r/FylFY1/2 It should work, but I can pass the