laravel-5.4

Laravel middleware with multiple roles

筅森魡賤 提交于 2019-11-27 10:24:27
问题 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

Laravel 5.4 Disable Register Route

人盡茶涼 提交于 2019-11-27 10:18:34
问题 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? 回答1: 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'); //

Laravel 5.4, 5.3 : customize or extend notifications - database model

本秂侑毒 提交于 2019-11-27 09:41:52
IMHO, the current Database channel for saving notifications in Laravel is really bad design: You can't use foreign key cascades on items for cleaning up notifications of a deleted item for example Searching custom attributes in the data column (casted to Array) is not optimal How would you go about extending the DatabaseNotification Model in vendor package? I would like to add columns event_id , question_id , user_id (the user that created the notification) etc... to the default laravel notifications table How do you override the send function to include more columns? In: vendor/laravel

mariaDB JSON support in Laravel

谁都会走 提交于 2019-11-27 06:55:38
问题 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')-

No hint path defined for [mail] Laravel 5.4

不问归期 提交于 2019-11-27 05:54:10
问题 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

Laravel 5.4 Specific Table Migration

ぃ、小莉子 提交于 2019-11-27 00:05:55
问题 Hi read all the included documentation here in https://laravel.com/docs/5.4/migrations. Is there a way on how to migrate a certain migration file (1 migration only), cause right now every time there is a change I use php artisan migrate:refresh and all fields are getting reset. 回答1: First you should create one migration file for your table like: public function up() { Schema::create('test', function (Blueprint $table) { $table->increments('id'); $table->string('fname',255); $table->string(

How to validate array in Laravel?

ぃ、小莉子 提交于 2019-11-26 21:47:13
I try to validate array POST in Laravel: $validator = Validator::make($request->all(), [ "name.*" => 'required|distinct|min:3', "amount.*" => 'required|integer|min:1', "description.*" => "required|string" ]); I send empty POST and get this if ($validator->fails()) {} as False . It means that validation is true, but it is not. How to validate array in Laravel? When I submit form with input name="name[]" Laran Asterisk symbol (*) means that you want to check VALUES in the array, not the actual array. $validator = Validator::make($request->all(), [ "name" => "required|array|min:3", "name.*" =>

Laravel: validate json object

為{幸葍}努か 提交于 2019-11-26 21:22:09
问题 It's the first time i am using validation in laravel. I am trying to apply validation rule on below json object. The json object name is payload and example is given below. payload = { "name": "jason123", "email": "email@xyz.com", "password": "password", "gender": "male", "age": 21, "mobile_number": "0322 8075833", "company_name": "xyz", "verification_status": 0, "image_url": "image.png", "address": "main address", "lattitude": 0, "longitude": 0, "message": "my message", "profession_id": 1,

Laravel 5.4 : Get logged in user id inside __construct()

倾然丶 夕夏残阳落幕 提交于 2019-11-26 17:17:22
问题 I am trying to access Auth::user()->id; inside constructor but it always return the error Trying to get property of non-object . I study in the laravel documentation that Session is not accessible inside constructor and also search on SO for this. I need logged in user id inside constructor because I have to fetch data from database and make it available for all its method. My current code is : public function __construct(){ $this->middleware('auth'); $induction_status = TrainingStatusRecord:

Laravel 5.4^ - How to customize notification email layout?

半城伤御伤魂 提交于 2019-11-26 16:15:04
问题 I am trying to customize the HTML email layout that is used when sending notifications via email. I have published both the mail and notification views. php artisan vendor:publish --tag=laravel-mail php artisan vendor:publish --tag=laravel-notifications If I modify the /resources/views/vendor/notifications/email.blade.php file, I can only change the BODY content of the emails that get sent. I am looking to modify the footer, header, and every other part of the email layout as well. I tried