laravel-5.4

How to get and validate application/json data in Laravel?

不想你离开。 提交于 2019-12-23 05:07:39
问题 I send data from client to server in application/json content type. Then I try to take this information in server side like as: public function register(Request $request) { $data = $request->json()->all(); var_dump($data); die(); } It returns me empty array() Also I tried to validate incoming POST using this: $validator = Validator::make($request->json()->all(), []); How to get and validate application/json data in Laravel? I get POST data like as: dd($_POST); array:1 [▼ "application/json" =>

How correctly deploy a Laravel application from my local environment to my remote server?

坚强是说给别人听的谎言 提交于 2019-12-23 04:31:13
问题 I am pretty new in Laravel and I have the following doubt. I have to migrate a Laravel 5.4 application that I have developed from my local environment to my remote server. Can I do it in the following way? Take the entire directory containing my local application and upload it into the /var/www/html directory of my remote server. Export my local database and import on my remote database. Change the content of the .env file. Now the application should work on my remote server. Is it correct or

Mail::queue not working

放肆的年华 提交于 2019-12-22 17:52:20
问题 i'm unable to queue emails in laravel 5.4. in previous laravel 5.3 projects all worked fine. Send is still working: Mail::send('email.blank', ['title' => 'nice', 'content' => 'message'], function ($message) { $message->from('a@b.com', 'test'); $message->to('a@b.com'); }); Queue does not work: Mail::queue('email.blank', ['title' => 'nice', 'content' => 'message'], function ($message) { $message->from('a@b.com', 'test'); $message->to('a@b.com'); }); With the following error:

Cache table values globally in laravel

谁都会走 提交于 2019-12-22 10:57:08
问题 I have a table: settings with the model Setting class Setting extends Model { protected $fillable = [ 'name', 'value', ]; } I have created a service provide SettingsServiceProvider and registered in app.php class SettingsServiceProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function boot(Factory $cache, Setting $settings) { if (\Schema::hasTable('settings')) { config()->set('settings', Setting::pluck('value', 'name')->all()); } } /** *

Command “tinker” is not defined

浪尽此生 提交于 2019-12-22 09:57:27
问题 After upgrade from 5.3 to 5.4, Follow the instructions: In order to continue using the tinker Artisan command, you should also install the laravel/tinker package: composer require laravel/tinker Once the package has been installed, you should add" Laravel\Tinker\TinkerServiceProvider::class to the providers array in your config/app.php configuration file. After hours of search..got this question but is not working. Any ideas? config.json { "name": "laravel/laravel", "description": "The

Pusher is not defined! Laravel 5.4 with Laravel Echo

你说的曾经没有我的故事 提交于 2019-12-22 09:19:15
问题 I don't know what is wrong with my codes Here's my app.js /** * First we will load all of this project's JavaScript dependencies which * include Vue and Vue Resource. This gives a great starting point for * building robust, powerful web applications using Vue and Laravel. */ require('./bootstrap'); /** * Next, we will create a fresh Vue application instance and attach it to * the page. Then, you may begin adding components to this application * or customize the JavaScript scaffolding to fit

Laravel 5.4 - 'updateOrCreate' method. Check If record was 'updated' or 'created'

只谈情不闲聊 提交于 2019-12-22 04:58:18
问题 Using the method updateOrCreate , is there a way to know which if a record was updated or created? UPDATE: I need to use this feature to return 201 , for created record, or 204 for updated record. Thank you. 回答1: Since updateOrCreate returns the model instance. https://github.com/laravel/framework/blob/5.4/src/Illuminate/Database/Eloquent/Builder.php#L374 You can check that a record was recently created using: $instance->wasRecentlyCreated https://github.com/laravel/framework/blob/5.3/src

Select all selected id's in a multiselect dropdown in laravel 5.4 with harvest chosen

可紊 提交于 2019-12-22 01:07:22
问题 I have a dropdown called designation, where a user can add some information against multiple designation. If I add 1 record against 3 designation, then I need to select those during validation and edit time also. Ex: Choosed id's {5,7,8} from [1 to 10]. <select id="forWhom" name="forWhom[]" multiple class="form-control chosen"> <option value="">--- Select ---</option> @foreach ($desgInfo as $key => $value) <option value="{{ $key }}" {{ old('forWhom',$info->forWhom) == $key ? 'selected' : ''}}

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

核能气质少年 提交于 2019-12-21 07:55:39
问题 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

Listen callback is not working in Pusher API Laravel 5.4

浪尽此生 提交于 2019-12-21 07:15:34
问题 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