laravel-5.3

How can display space in view blade laravel 5.3?

本秂侑毒 提交于 2020-01-17 04:44:06
问题 My records in db is like this : I want to display with space I try like this : {{ nl2br($text) }} and {{ nl2br(e($text)) }} It does not work How can I solve it? 回答1: have you tried using {!! !!} here you can use HTML entity &nbsp 回答2: you can create a helper like this $output = nl2br(str_replace(" ", "  ", $db_record)); Then your blade file {!! $output !!}; 来源: https://stackoverflow.com/questions/43714169/how-can-display-space-in-view-blade-laravel-5-3

Why mail laravel not working on the staging server?

泪湿孤枕 提交于 2020-01-16 18:04:07
问题 I try on the my localhost, it works But if I try on the staging server, it does not works My controller like this : <?php use Illuminate\Support\Facades\Mail; use App\Mail\OrderReceivedMail; ... class PurchaseController { ... public function test() { $order = $this->order_repository->find(416); $user = $this->user_repository->find(1); Mail::to($user)->send(new OrderReceivedMail($order, $order->store)); } } My mail like this : <?php namespace App\Mail; use Illuminate\Bus\Queueable; use

Laravel 5.3 Passport Custom Grants?

老子叫甜甜 提交于 2020-01-13 07:37:12
问题 I know I am not the only person who has come up to this point. Does anyone know how to properly implement a custom grant in Laravel(5.3) Passport? Or Have a good link/tutorial to reference how to properly do it? I know there's this package: https://github.com/mikemclin/passport-custom-request-grant But I'm asking for a more "Do it yourself" approach. Thank you in advance. 回答1: namespace App\Providers; use App\Auth\Grants\FacebookGrant; use Illuminate\Foundation\Support\Providers

Laravel Scheme Builder is adding auto_increment to all integer fields which makes it fail

跟風遠走 提交于 2020-01-13 06:25:09
问题 When I try to use PHP Laravels Database Migration and schema builder I keep getting the error below on any tabvle that has an auto incrementing ID column and a regular user_id integer column. The error below shows that the user_id column SQL is being generated with the value auto_increment on the user_id and my code does not tell it to do that anywhere! I am using Laravel v5.3 My schema code is: public function up() { Schema::create('bookmark_tag_lists', function(Blueprint $table) { $table-

Laravel 5.3 LoginController - Header may not contain more than a single header, new line detected

左心房为你撑大大i 提交于 2020-01-11 09:03:19
问题 I have a problem when changing the default LoginController redirect after login, I'm getting an ErrorException in Response.php line 339: Header may not contain more than a single header, new line detected I have already tried everything but it just does not work, the code is: class LoginController extends Controller { protected $redirectTo = '/home'; protected function redirectTo() { if (\Auth::check()) { $user_id = \Auth::id(); $usuario = users::where('id','=',$user_id)->first(); if($usuario

How to optimize code in Laravel?

倖福魔咒の 提交于 2020-01-11 07:49:09
问题 I use the following code to get data from two related tables: $arr = []; $objectModel = new ProductCategory(); $objectModel::$language = 2; $subcategories = $objectModel::with("translate", "parent")->get(); foreach($subcategories as $key => $item) { $arr[$item->translate()->first()->objectId] = $item->translate()->first()->name; } array_unshift($arr, 'Select category'); return $arr; In result this part of code I get array with key => value to insert this in select list in Blade template. But

Laravel 5.3 - Attach Multiple Files To Mailables

六眼飞鱼酱① 提交于 2020-01-10 18:17:14
问题 How does one go about attaching multiple files to laravel 5.3 mailable? I can attach a single file easily enough using ->attach($form->filePath) on my mailable build method. However, soon as I change the form field to array I get the following error: basename() expects parameter 1 to be string, array given I've searched the docs and also various search terms here on stack to no avail. Any help would be greatly appreciated. Build Method: public function build() { return $this->subject(

How can I update pivot table on laravel?

喜你入骨 提交于 2020-01-10 06:06:12
问题 I use laravel 5.3 I have 3 table : table product, table category and table products_categories table product : id, name, etc table category : id, name, etc table products_categories : id, product_id, category_id In model product, I have method this : public function categories() { return $this->belongsToMany(Category::class, 'products_categories', 'product_id', 'category_id') ->withPivot('id') ->withTimestamps(); } So 1 product have many category My code like this For example $param['category

How can I update pivot table on laravel?

99封情书 提交于 2020-01-10 06:06:06
问题 I use laravel 5.3 I have 3 table : table product, table category and table products_categories table product : id, name, etc table category : id, name, etc table products_categories : id, product_id, category_id In model product, I have method this : public function categories() { return $this->belongsToMany(Category::class, 'products_categories', 'product_id', 'category_id') ->withPivot('id') ->withTimestamps(); } So 1 product have many category My code like this For example $param['category

laravel upload files in many inputs

混江龙づ霸主 提交于 2020-01-07 04:38:06
问题 I'm trying to upload files in 4 inputs files i get the solution from here but the problem the last file4 input file uploaded in all fields in database in my blade form {!! Form::file('file1', null,['class'=>'form-control']) !!} {!! Form::file('file2', null,['class'=>'form-control']) !!} {!! Form::file('file3', null,['class'=>'form-control']) !!} {!! Form::file('file4', null,['class'=>'form-control']) !!} in my controller $input = $request->all(); $files =[]; if ($request->file('file1'))