laravel-5.4

How to update multiple rows from a single query using eloquent/fluent?

淺唱寂寞╮ 提交于 2019-12-10 16:58:45
问题 I was learning about How to insert multiple rows from a single query using eloquent/fluent and I found the answer here Can somebody share any documentation about how to update bulk rows in single query? My queries are below. Update tblrole set role = 'Super Admin' where RoleID = 1; Update tblrole set role = 'Super Admin A' where RoleID = 2; Update tblrole set role = 'Super Admin B' where RoleID = 3; Update tblrole set role = 'Super Admin C' where RoleID = 4; 回答1: You cannot do anything like

How to do unit testing with Laravel Localization?

会有一股神秘感。 提交于 2019-12-10 15:53:27
问题 I'm using mcamara/laravel-localization package and I can't figure out how to make it work with my unit tests. Both of the following fail with red: // 1. This one results in "Redirecting to http://myapp.dev/en" $this->get('/')->assertSee('My App Homepage'); // 2. This one results in 404 $this->get('/en')->assertSee('My App Homepage'); In the browser, http://myapp.dev returns 302 with a redirect to http://myapp.dev/en , fair enough. However, http://myapp.dev/en returns 200. So both cases work

Laravel - Can't save files to public_path using storeAs

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 14:46:04
问题 I cannot upload files to the public_path folder in Laravel 5.4. I can't understand what's going wrong, the documentation makes it look easy. $request is the POSTed contents of a form. filename is a file submitted via the form. public function uploadFile($request) { if ($request->hasFile('filename') && $request->file('filename')->isValid()) { $file = $request->filename; $hash = uniqid(rand(10000,99999), true); $directory = public_path('files/'.$hash); if(File::makeDirectory($directory, 0775,

Get Email Address from socialite while login with Gmail

我们两清 提交于 2019-12-10 14:25:19
问题 I am following this article to login with Google . I am able to redirect to gmail login successfully. Also, it goes to callback url successfully. Below is my code public function showGoogleLoginForm() { $providerKey = \Config::get('services.google'); return \Socialite::driver( 'google' )->scopes(['profile', 'email'])->redirect(); } Problem I am now trying to check if the callback gives me the email address of the user or not. So that, I could check that user is registered in my database or

Behat hangs when there are multiple scenarios, but works on a single one

懵懂的女人 提交于 2019-12-10 14:10:20
问题 I have Behat test cases written like so: Feature: Checkout In order to buy products As a customer I need to be able to checkout items in the cart Background: Given step 1 And step 2 @Ready Scenario: Deliver now When step 3 Then step 4 @NoneReady Scenario: Deliver later When step a Then step b And step c @AddressNotCovered Scenario: Address Not Covered When step i Then step ii If I run behat on a single tag, it works just fine: $ behat --tags=Ready Feature: Checkout In order to buy products As

Laravel 5.4 on Heroku. Forbidden You don't have permission to access / on this server

大憨熊 提交于 2019-12-10 13:56:14
问题 I have deployed my laravel 5.4 app on Heroku. The problem is, I am getting this error message: Forbidden You don't have permission to access / on this server My Procfile: web: vendor/bin/heroku-php-apache2 public/ Looking into the log, I find that it has been trying 'app/' instead of '/'. My log , snipped for readability. 2017-12-03T14:18:45.747195+00:00 app[web.1]: [Sun Dec 03 14:18:45.746749 2017] [autoindex:error] [pid 122:tid 140692458305280] [client 10.140.221.43:41026] AH01276: Cannot

how to read FormData object in Laravel

徘徊边缘 提交于 2019-12-10 13:35:25
问题 I am trying to ajax submit form to a Laravel 5 controller method. I understand that in php, you can define a FormData object, append the input fields to the object and send it to the server where you can now extract the values using the input field names. Like so: var form_data = new FormData(); formdata.append('file_name', 'some_file_name_from_form.png'); When form_data is sent as the data in the ajax call, I can get the file in PHP by using the $_FILES['file_name']['name']; . So I tried

How to rewrite SQL query in Laravel?

六月ゝ 毕业季﹏ 提交于 2019-12-10 12:16:25
问题 I use the following Query Builder: $res = Announcement::whereExists(function ($query) { $query->select(DB::raw(1)) ->from('announcement_category') ->join('user_category', 'user_category.category_id', '=', 'announcement_category.category_id') ->where('user_category.user_id', 1) ->where('announcement_category.announcement_id', '=', 'announcements.id') ->whereNull('deleted_at'); })->get(); How to rewrite this query using short form with : Announcement::with("announcement_category")... Because,

Mix/version images in Laravel 5.4?

耗尽温柔 提交于 2019-12-10 11:06:20
问题 I want to use mix on a set of images. First I copy them: mix.copy('resources/images', 'public/images'); Then version: mix.version(); The above does nothing to the images. I've also tried specifying the path: mix.version('public/images/*'); But I get a no such file or directory error. How can I version the images? 回答1: I know it's an old question, but for 2019 - laravel mix 4 you can use: mix.copy('resources/images/*', 'public/images'); mix.version(); This will version all your copied files.

Laravel + Image Intervention : Force download of file that is not saved

ぐ巨炮叔叔 提交于 2019-12-10 11:00:32
问题 I want to simply upload files , resize them and then force a download for every uploaded file. I do not want to save the files. Resizing etc. works fine, however I cannot manage to force the download of the new file. $content = $image->stream('jpg'); return response()->download($content, $name); The shown snippet results in is_file() expects parameter 1 to be a valid path, string given Most probably because $content is not a path but the actual data. Is there a way to enforce the download