laravel-5.4

Better Way to use Laravel old and Vue.js

泄露秘密 提交于 2019-12-01 12:34:34
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 Vue really expects you to init data from the view model which then updates the view, however, you want to use data in

How to get object from nested Eager Loading Laravel?

拜拜、爱过 提交于 2019-12-01 12:23:10
问题 In query I use Nested Eager Loading: $res = User::where("id", 1)->with("categories.categoryAnn.announcements")->get(); In result of this query I get nested collections: Collection->User->categories->categoryAnn->announcements How to shortly get last nested object announcements ? 回答1: You can do it the opposite way to get only announcements like this: $announcements = Announcement::whereHas('categoriesAnn', function($q) { $q->whereHas('categories, function($q) { $q->whereHas('user', function(

How to store array cookie in laravel 5.4?

大憨熊 提交于 2019-12-01 12:15:38
I have this function in laravel 5.4 but I get error. $cart[$product->id] = $quantity; var_dump($cart); return redirect('catalogs')->withCookie(cookie()->forever('cart', $cart)); var_dump($cart) contains this: array(1) { [1]=> string(1) "1" } Error warning: Method Symfony\Component\HttpFoundation\Cookie::__toString() must not throw an exception, caught ErrorException: Array to string conversion If I passed just string value (not array), it success. If there any way to store array cookie in Laravel? Thank you. Only strings can be stored in a cookie. So try this: $cart[$product->id] = $quantity;

How to set where in relation Laravel?

房东的猫 提交于 2019-12-01 08:21:00
问题 I use the following construction for joining tables: with("attachments", "offers.publisher"). public function publisher() { return $this->belongsTo("App\User", "user_id", "id"); } How to join publisher relation only when offers.status = 1 ? In other words I need to use publisher by condition Where I tried also this: $announcements = Announcement::whereHas('offers', function($q) { $q->with("publisher")->where('status', 1); })->get(); 回答1: The best way would to just have two definitions,

a session error after updating to laravel 5.4

怎甘沉沦 提交于 2019-12-01 06:28:34
After updating from laravel 5.3 to 5.4, I encountered an error in vendor. The error is: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Illuminate\Session\Store::set() in /var/www/ostadbank.com/vendor/laravel/framework/src/Illuminate/Support/Manager.php:137 But when I go to my error is: fatal error exception in Manager.php line 137:call to undefined method Illuminate\session\store::set() I go to manager.php line 137 and I see the line below: public function __call($method, $parameters) { return $this->driver()->$method(...$parameters); } I am not sure where to

Laravel 5.4 blade foreach loop

给你一囗甜甜゛ 提交于 2019-12-01 05:53:20
问题 I am building a venue manangement system, and on the landing page, i m trying to show all the available slots to the visitors. The ones that have already been booked are shown as not available. I have created two variables, one that carries the info from the time table and the other from the booking table and tyring to use blade to compare and show. This is how I am trying to implement it in blade: @foreach($times as $time) @foreach($bookings as $booking) <tr> @if($time->availble_times ==

a session error after updating to laravel 5.4

泪湿孤枕 提交于 2019-12-01 04:48:14
问题 After updating from laravel 5.3 to 5.4, I encountered an error in vendor. The error is: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Illuminate\Session\Store::set() in /var/www/ostadbank.com/vendor/laravel/framework/src/Illuminate/Support/Manager.php:137 But when I go to my error is: fatal error exception in Manager.php line 137:call to undefined method Illuminate\session\store::set() I go to manager.php line 137 and I see the line below: public function _

Running Laravel Dusk on Headless (no GUI) machine

混江龙づ霸主 提交于 2019-12-01 03:44:00
问题 With the recent announcement of Laravel 5.4, I thought I'd give it a try. Like Ozymandias-X on Reddit, I also have been frustrated by it. My Setup Windows 10 as Host; CentOS 7 as Guest (no GUI installation, no Vagrant) Shared folder with Virtual Box. If I just turn on my machine and run php artisan dusk , I get the following: [08:14 AM]-[root@php7]-[/var/www/html/admin]-[git master] # php artisan dusk PHPUnit 5.7.11 by Sebastian Bergmann and contributors. E 1 / 1 (100%) Time: 25.91 seconds,

Composer View is not loading variable into view

亡梦爱人 提交于 2019-12-01 02:47:49
问题 I created 3 composer views previously and they all work properly, but then I created another one, which doesn't seem to work. I've been trying to get it to work, it doesn't seem to be something related to my code. I will drop a piece of it here, but I still don't think it's the code. Provider EvenComposerProvider: public function register(){ $this->composeEven(); } public function composeEven(){ view()->composer('includes.aklinkosesi', 'App\Http\Composers\EvenComposer'); } Composer

How to redirect to a route from a controller method

假如想象 提交于 2019-12-01 00:03:51
I have defined a method in my controller, where inputs are first retrieved, and if the email field is present in my database, I would like to return a view. However, if the email field isn't present, I would like to redirect to another route. I would also like to pass in the inputs to that route as well. To better understand what I mean, my code is as follows for my controller: public function index(Request $request) { $credentials = $request->all(); if (\App\User::where('email','=',$credentials['email'])->exists()){ //if they are registered, return VIEW called welcome, with inputs return view