laravel-5.4

Missing argument 1 for Illuminate\Support\MessageBag::has()

一世执手 提交于 2019-12-07 08:29:09
问题 When i access my Laravel Project. It Returns Following Errors. How to Solve It. Missing argument 1 for Illuminate\Support\MessageBag::has(), called in /var/www/laravel/vendor/laravel/framework/src/Illuminate/Support/ViewErrorBag.php on line 92 and defined (View: /var/www/laravel/resources/views/welcome.blade.php) In my Blade Code : @if ($errors->has()) <div class="alert alert-danger"> @foreach ($errors->all() as $error) {{ $error }}<br> @endforeach </div> @endif 回答1: Check this line: @if (

How to implement eloquent events in laravel using commmon Trait for all models

点点圈 提交于 2019-12-07 08:23:46
问题 I am using laravel 5.4 to create a web app. I have created a trait to implement events for created, updated, deleted and restored eloquent events. I have created a trait as below: <?php namespace App\Traits; use Auth; use App\Master\Activity; use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; /** * Class ModelEventLogger * @package App\Traits * * Automatically Log Add, Update, Delete events of Model. */ trait ActivityLogger { /** *

How do I make Example.vue update in Laravel?

杀马特。学长 韩版系。学妹 提交于 2019-12-07 07:32:27
I just read the answers to this question and wasn't able to get a good response. Laravel Example.vue not updating I also posted this question trying to figure it out on my own but to no avail. how do I load a Vue component in Laravel 5.4? As another attempt, I just did a new reinstall of Laravel, and while I am able to get the default Example.vue component to load multiple times in a single view, I am still unable to change the contents of the component. Funnier thing is that when I run npm install and then npm run dev, the component ceases to even show up anymore. This is really frustrating

laravel eager loading using with() vs load() after creating the parent model

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 06:44:46
问题 I am creating a Reply model and then trying to return the object with it's owner relation. Here is the code that returns an empty object: //file: Thread.php //this returns an empty object !!?? public function addReply($reply) { $new_reply = $this->replies()->create($reply); return $new_reply->with('owner'); } However, if i swap the with() method for load() method to load the owner relation, i get the expected result. That is the reply object is returned with it's associated owner relation: /

laravel 5.4 modify data before validation in request [closed]

孤街浪徒 提交于 2019-12-07 03:40:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I have my custom Request, which extends the Backpack CrudController. Now I would like to override the prepareForValidation of the ValidatesWhenResolvedTrait since it looks like the right place to modify my incoming data, but I can't figure out how ... So my first question is, can I override this method? Its

How can I change the public path to something containing an underscore in Laravel Mix?

馋奶兔 提交于 2019-12-06 19:20:57
问题 In Laravel 5.4 Mix was introduced to compile assets and maintain the asset pipeline. Mix defaults to your public directory being named public . In many cases, including mine, my public directory is called something else. In my case, it's public_html . How can I change the public directory where assets are compiled to? I have tried changing the paths within webpack.min.js to: mix.js('resources/assets/js/app.js', 'public_html/assets/js') .sass('resources/assets/sass/app.scss', 'public_html

eval() in laravel not executing the string

早过忘川 提交于 2019-12-06 17:05:45
问题 My database table contains an eloquent query click here to see Database Table Snapshot .I have fetched the query from database.Now problem is that I'm unable to execute the query that is in the collection. I have Tried eval() to execute the query present the collection.But eval() is not executing it. eval("\"$tempdata\";"); $tempdata contains the query that is in the database table. 回答1: You need to add return when using eval. Try: eval("return $tempdata;"); Hope this helps! 来源: https:/

how to guard a controller through multiple of user?

瘦欲@ 提交于 2019-12-06 17:01:00
问题 It is project requirement. where i have multiple logins but some user can not access few module. like super admin and analyst can access all module but developer can only use own controller. so in this case , how can i guard a controller with multiple logins. also note that i have separate login page and table into Database. for Example phonebookController can be access by super admin and analyst but not by developers. so please tell me how can i implement this? i use this for :: if( Auth:

Laravel 5.4: Password reset token custom length?

依然范特西╮ 提交于 2019-12-06 16:54:43
I am using laravel 5.4 building an API where I email the user a token on password reset if user verified, which user provides before resetting password. Currently the sent token has 64 characters and too large for user to grab, and I'm not sure if laravel has configuration to give a custom length to token? The solution is a little bit tricky, ill try to explain the procedure as clearly as possible: STEP 1 - Extend the standard DatabaseTokenRepository Create a class that extends Illuminate\Auth\Passwords\DatabaseTokenRepository in order to define a new token creation policy. <?php namespace App

How to remove quotes from SQL query Laravel?

让人想犯罪 __ 提交于 2019-12-06 16:54:32
I have the following query: $this->data = \DB::table('months')->select(DB::raw("months.id, COUNT(transactions.id) as total")) ->leftJoin('transactions', function($join) { $join->on('months.id', '=', DB::raw('MONTH(created_at)')) ->on('transactions.doctor_id', '=', $this->user_id); }) ->groupBy('months.id') ->get(); It involks an error on line ->on('transactions.doctor_id', '=', $this->user_id); . It added single quotes for variable $this->user_id . How to avoid this eroros: SQLSTATE[42S22]: Column not found: 1054 Unknown column '2' in 'on clause' (SQL: select months.id, COUNT(clients.id) as