laravel-5.4

How to access the contents of this collection in laravel/php

Deadly 提交于 2019-12-04 06:23:54
问题 I am new to Laravel and doing a project to build a mini-social network app.I have a post model that has a relationship with the user model. I have a Post page, where only the posts of the authenticated user and his/her friends will show. In my PostController, i queried for the friends of the authenticated user like so; $friends = Auth::user()->friends(); Where the friends() object has earlier been defined in my friendable trait. That works well as shown in the screen shot. I tried to query

Is starting route grouping with namespace() not allowed in Laravel 5.4?

柔情痞子 提交于 2019-12-04 02:41:11
Using Laravel 5.4, indeed in the documentation about Route grouping, and an example as this was given about namespacing : Route::namespace('Admin')->group(function () { // Controllers Within The "App\Http\Controllers\Admin" Namespace }); This according to the doc is okay, but after installing Laravel 5.4.30 I discovered that doing the above throws the following error: PHP Parse error: syntax error, unexpected 'namespace' (T_NAMESPACE) in /Applications/MAMP/htdocs/my_app/routes/web.php on line Even though I did a workaround by using other route methods before it such as the following: Route:

Better Way to use Laravel old and Vue.js

谁说我不能喝 提交于 2019-12-04 02:15:52
问题 Im working using vue.js 2.0 and Laravel 5.4 I would like to know if exits a better way to send data Controllers -> views without lost the value, overwrite by the v-model Because after charge vue.js this take the value in data that is define in this way data: { ciudad:'', } If I try to do something like that <input class="form-control" id="ciudad" name="ciudad" type="text" v-model="documento.ciudad" value="{{ $documento->ciudad }}" > I lost the value sending by the controller 回答1: Vue really

Laravel 5.4 wrongly mix HTML components in Markdown Mailable

杀马特。学长 韩版系。学妹 提交于 2019-12-04 02:03:11
I had ordinary Mailable that had some hardcoded content. I've published mailable views, changed content to markdown and replaced ->view with ->markdown . Now mail have nicely formated markdown. However Laravel after compiling that markdown will pick HTML component definitions, for reasons I can not phantom. And that after it used Markdown version for message, so it's mixing both kinds in a single Mailable markdown view! I've tried: php artisan cache:clear php artisan view:clear adding markdown to html components - wont work, Laravel use them past markdown compilation step changing ->markdown

Listen callback is not working in Pusher API Laravel 5.4

房东的猫 提交于 2019-12-04 00:23:50
Problem I can confirm that Pusher API is receiving the message. I saw in Debug console of Pusher website. But listen callback is not working at all. I am following this tutorial to implement Pusher in Laravel 5.4 Below were the step by step things done. composer require pusher/pusher-php-server npm install --save laravel-echo pusher-js instantiated the Echo instance in your resources/assets/js/bootstrap.js Initialized the pusher key in env and in bootstrap.js file. Finally, I wrote below code in blade. <script> window.Echo.channel('SendMessageChannel.1') .listen('App.Events.SendMessageEvent',

Laravel Blade - Chain/Embed multiple layouts

孤街醉人 提交于 2019-12-04 00:17:26
In my favorite templating frameworks they typically have the ability to nest layouts. Is this something that is possible in Blade? For example... master.blade.php <html> <head><!-- stuff --></head> <body> @yield('content') </body> </html> nav.blade.php @extend('master') <nav> <!-- nav content --> </nav> @yeild('content') breadcrumb.blade.php @extend('nav') <breadcrumb> <!-- breadcrumb content --> </breadcrumb> @yield('content') home.blade.php @extend('nav') @section('content') <home> <!-- content --> </home> @endsection about.blade.php @extend('breadcrumb') @section('content') <about> <!--

Method validate does not exist - Laravel 5.4

久未见 提交于 2019-12-03 23:23:06
I have a very weird problem. When I'm submitting the form, it throws an error with server-side validation. Here is my simple controller: namespace App\Http\Controllers; use Newsletter; use Illuminate\Http\Request; class SubscriptionController extends Controller { public function subscribe(Request $request) { $request->validate([ 'email' => 'required|email', ]); } } Submitting the form gives me: BadMethodCallException Method validate does not exist. it should work according to: https://laravel.com/docs/5.4/validation arku In docs said: $this->validate($request, [ 'email' => 'required|email', ])

Laravel eloquent UUID in a pivot table

岁酱吖の 提交于 2019-12-03 22:56:10
问题 This question is like this one: laravel uuid not showing in query . However, the difference in this question is about that table is a pivot table with id field uses UUID generated via MySQL trigger on insert. I don't want to create another model for that pivot table to supply it with the solution regarded on the similar question's answer. So, is there any way to perform type casting of the pivot table from another model related to it? 回答1: I think this might be what you want: In your model

Laravel validation Error messages to string

时光总嘲笑我的痴心妄想 提交于 2019-12-03 16:19:01
I want to convert laravel validation error array to a comma separated string. This is to use in an api service for an ios application. So that the iOs developer can process error messages easily. I tried, $valArr = []; foreach ($validator->errors() as $key => $value) { $errStr = $key.' '.$value[0]; array_push($valArr, $errStr); } if(!empty($valArr)){ $errStrFinal = implode(',', $valArr); } But it is not working. You should do like this : $errorString = implode(",",$validator->messages()->all()); P.S. Assuming $validator = Validator::make($dataToBeChecked,$validationArray,$messageArray) The

Disable error reporting entirely in Laravel production?

纵饮孤独 提交于 2019-12-03 12:52:57
问题 I would like to disable error reporting entirely on production, because we have some very old code we still need to fix but for now does work (yes I don't like it either). We cannot fix everything in a few days, so we need to just supress the warnings and exceptions like we always did. The real problem is that it already throws an exception on a simple lazy bug like (because var is not defined) if(!$var) { // do whatever } tried APP_DEBUG=false APP_LOG_LEVEL=emergency display_errors(false);