laravel-5.4

Laravel - Middleware triggered while it should not?

冷暖自知 提交于 2019-12-11 06:14:33
问题 I'm using Laravel 5.4 and Vuejs 2.3 along with VueRouter I have a website that consists of two parts example.com example.com/tools Problem If I am at example.com/tools and if I reload the page to the same address example.com/tools the middleware checkUsersPublic is triggered whereas it is only linked to / . Edit If I remove { path: '/tools', component: Stats } from VueRouter.js the middleware is not triggered anymore Question What should I do change so the middleware is not triggered ? Routes

Column not found laravel 5.4

此生再无相见时 提交于 2019-12-11 06:03:36
问题 I get the following error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'books.id' in 'where clause' (SQL: select * from books where books . id = 98745632564 limit 1) when I pass id value as id. I have column name bookID in my database but in the above error it is comparing books.id = 98745632564. I could not understand where book.id is coming from. public function showBook($id){ $book = Book::findOrFail($id); return $book; } The code works perfectly fine when I pass id value with

Laravel 5.4: How to DO NOT use route parameter in controller

回眸只為那壹抹淺笑 提交于 2019-12-11 05:32:07
问题 I am developing a Multilingual application and trying to make a middleware to pass route {locale} prefix to URL. But now I do not need to use this {locale} parameter in controller, for example: public function getPost(App\Post $post) { return view('welcome')->withPost($post); } But the code above does not work unless I change the App\Post $post to $locale, App\Post $post . The problem is because I'll need to pass the $locale parameter whenever I create a new controller. That is not cool. How

How to get avatar url which are stored at storage directory using laravel 5.4?

筅森魡賤 提交于 2019-12-11 05:22:51
问题 I want to get the url of stored avatar inside the storage directory, i am using laravel 5.4. Actually i am using following method for uploading image and get the url. Uploading Image: <input type="file" class="form-control" value="{{ old('u_avatar') }}" name="u_avatar" /> In the Controller $UserModel->u_avatar = $request->file('u_avatar')->store('avatars'); // Uploading Files properly in the storage/app/avatars Getting Image I have tried following two methods for getting the images, but both

laravel 5.4 custom error message for MIME not working?

☆樱花仙子☆ 提交于 2019-12-11 05:18:56
问题 Dearest, I want to make a custom error message for uploaded image, here's my controller code : protected function validator($data = [], $validateContent = []){ $messages = [ 'imgUserAvatar:mimes' => 'File Type must be in jpeg,jpg,png' ]; return Validator::make($data, $validateContent, $messages); } $validateContent = [ 'imgUserAvatar' => 'mimes:jpeg,jpg,png|max:2000', 'textUserEmail' => 'required|unique:admin_user,user_email|max:50', 'textFirstName' => 'required|max:50', 'textLastName' =>

laravel 5 inner join and group by query syntax error

蓝咒 提交于 2019-12-11 05:18:02
问题 please help me with my format query in laravel 5. I am a beginner in using laravel 5, and i just search to came up with this query, but now i am getting error i dont know where and why? i think my error is only in syntax? Here is my code: $date = date("Y-m-d", strtotime($request->datepicker2)); $products = DB::table('shipping_table') ->select('products.product_name', 'products.price', 'Sum(shipping_products.quantity) AS qtysold', 'shipping_table.sold_date') ->join('shipping_products',

laravel 5 route passing two parameters

北城余情 提交于 2019-12-11 05:08:46
问题 i have this route Route::get('/artist/{id}/{name}', 'HomeController@artist')->where(['id' => '[0-9]+', 'name' => '[a-z]+'])->name('artist'); and this is my link <a href="{{route('artist',$artist->id,$artist->name)}}">{{$artist->name}}</a> and this is the artist method on HomeController public function artist($id, $name){ $artist = Artist::where('id', $id)->where('name', $name)->first(); return view('front.artist', compact('artist')); } i donot know this display error. this is the error. so

How to validate the file name in Laravel 5.4

蹲街弑〆低调 提交于 2019-12-11 04:52:38
问题 I have a form with three input fields. I want to validate the input value before processing them. Where I want to validate the file name before processing it. I use regular expression and alpha_dash. But I got an error for a valid file name. I want my file name only to contain small letter, numbers, underscore and dashes. How can I check the validation of the file name for my file? Html <form action="create" method="POST" enctype="multipart/form-data"> {{csrf_field()}} <table cellpadding="2"

How to store data in VueJS with Laravel 5.4

吃可爱长大的小学妹 提交于 2019-12-11 04:39:56
问题 Im building application like real time dashboard. Using many databases and external APIs. (The first Idea was AJAX + Laravel Queues, but I found VueJS and It's interesting.) The idea is to get the data in background with Laravel Queues from all sources and then storage it localy. Next step is getting this data with VueJS. The problem I have is the storage part. I dont have idea and actually dont know how to store it so VueJS can efficiently get this data from storage and on the other hand

How to set cookie in laravel 5.4?

邮差的信 提交于 2019-12-11 04:04:26
问题 I have this function in laravel 5.4 but I cant get anything from cookie. Cookie::queue('currentLang', 'heb', 999999999); echo $request->cookie('currentLang'); But I am getting some long string and not what I set. 回答1: Laravel has a cookie helper! /** * Create a new cookie instance. * * @param string $name * @param string $value * @param int $minutes * @param string $path * @param string $domain * @param bool $secure * @param bool $httpOnly * @return \Symfony\Component\HttpFoundation\Cookie */