laravel-5.4

How to store array cookie in laravel 5.4?

两盒软妹~` 提交于 2020-04-06 22:16:03
问题 I have this function in laravel 5.4 but I get error. $cart[$product->id] = $quantity; var_dump($cart); return redirect('catalogs')->withCookie(cookie()->forever('cart', $cart)); var_dump($cart) contains this: array(1) { [1]=> string(1) "1" } Error warning: Method Symfony\Component\HttpFoundation\Cookie::__toString() must not throw an exception, caught ErrorException: Array to string conversion If I passed just string value (not array), it success. If there any way to store array cookie in

How to store array cookie in laravel 5.4?

非 Y 不嫁゛ 提交于 2020-04-06 22:15:38
问题 I have this function in laravel 5.4 but I get error. $cart[$product->id] = $quantity; var_dump($cart); return redirect('catalogs')->withCookie(cookie()->forever('cart', $cart)); var_dump($cart) contains this: array(1) { [1]=> string(1) "1" } Error warning: Method Symfony\Component\HttpFoundation\Cookie::__toString() must not throw an exception, caught ErrorException: Array to string conversion If I passed just string value (not array), it success. If there any way to store array cookie in

Private channel not working with Laravel echo server

拜拜、爱过 提交于 2020-04-06 04:11:04
问题 I'm getting this JS error on the console: app.js:167 Uncaught ReferenceError: receiverId is not defined Here is my complete code: PrivateChatController: event(new PrivateMessageEvent($chat, $receiverId)); PrivateMessageEvent: namespace App\Events; use Illuminate\Broadcasting\Channel; use Illuminate\Queue\SerializesModels; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting

Private channel not working with Laravel echo server

旧街凉风 提交于 2020-04-06 04:07:49
问题 I'm getting this JS error on the console: app.js:167 Uncaught ReferenceError: receiverId is not defined Here is my complete code: PrivateChatController: event(new PrivateMessageEvent($chat, $receiverId)); PrivateMessageEvent: namespace App\Events; use Illuminate\Broadcasting\Channel; use Illuminate\Queue\SerializesModels; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting

Private channel not working with Laravel echo server

笑着哭i 提交于 2020-04-06 04:07:09
问题 I'm getting this JS error on the console: app.js:167 Uncaught ReferenceError: receiverId is not defined Here is my complete code: PrivateChatController: event(new PrivateMessageEvent($chat, $receiverId)); PrivateMessageEvent: namespace App\Events; use Illuminate\Broadcasting\Channel; use Illuminate\Queue\SerializesModels; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting

How to redirect to previous page after successful register in Laravel?

家住魔仙堡 提交于 2020-03-23 12:04:22
问题 Right now redirectTo is set to /home. I want to know how I can redirect to the previous page. I tried using protected $redirectTo = URL::previous(); but I get parse error, expecting ','' or ';'' What would be the best solution to approach this problem? I assume I'd need to over-ride the $redirectTo variable somehow with URL::previous() and that would be sufficient. This is my register controller: namespace App\Http\Controllers\Auth; use App\User; use URL; use App\Http\Controllers\Controller;

Validation rules required_if with other condition (Laravel 5.4)

坚强是说给别人听的谎言 提交于 2020-03-18 04:48:22
问题 I got a problem with validation rules with nested conditions. class StoreRequest extends Request { public function authorize(){ return true; } public function rules(){ return [ 'type_id' => 'required|integer', 'external_id' => 'required_if:type_id,==,3|integer', ]; } } Indeed I want to : - check the external_id only if the type_id equal to 3 - and check if it's an integer. When I post my form, the rules works when I select a type_id equal to 3. But if I select another type_id, like 1 or 2,

Session not persist on Laravel 5.4

时光总嘲笑我的痴心妄想 提交于 2020-02-24 07:54:37
问题 I'm having some problems with Laravel Sessions, now I'm working under Laravel 5.4, so, I'm using this code for set session: $request->session()->put('usuario', 'somevalue'); But when I'm trying to get the session value from another function on same controller with this code: $request->session()->get('usuario'); I'm getting NULL, I'm trying importing Session and using "web" middleware use Illuminate\Support\Facades\Session; But I still getting same error. Routes: Route::group(['middleware' =>

Laravel dompdf error “Image not found or type unknown”

倾然丶 夕夏残阳落幕 提交于 2020-02-03 08:25:30
问题 I am getting error "Image not found or type unknown" after downloading PDF in Laravel 5.4 using dompdf package. Here is the method public function pdf() { $users = User::get(); $pdf = PDF::loadView('pdf', compact('users')); return $pdf->download('Users.pdf'); } My view file <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>PDF</title> </head> <body> <div class="container"> <div class="row"> @foreach ($users as $user) <img src="public/storage/images/{{ $user->profile_pic }}

Laravel dompdf error “Image not found or type unknown”

柔情痞子 提交于 2020-02-03 08:23:42
问题 I am getting error "Image not found or type unknown" after downloading PDF in Laravel 5.4 using dompdf package. Here is the method public function pdf() { $users = User::get(); $pdf = PDF::loadView('pdf', compact('users')); return $pdf->download('Users.pdf'); } My view file <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>PDF</title> </head> <body> <div class="container"> <div class="row"> @foreach ($users as $user) <img src="public/storage/images/{{ $user->profile_pic }}