laravel-5.1

use QueryScope in Blade template

拥有回忆 提交于 2019-12-25 03:02:08
问题 I have define scope in model like this class Station extends Model { protected $primaryKey = 'st_id'; public function scopeByDid($query) { return $query->groupBy("st_did"); } } I can call byDid from controller but I cannot get it through blade template like this @foreach ($river->stations->byDid as $didType) .... @endforeach how do I get it. Appreciate your response. Thanks 回答1: If you're getting a relationship as an attribute (without () at the end) it means the relationship will have

Filtering the data does not work after adding the relational table: Laravel 5.2

蓝咒 提交于 2019-12-25 01:49:21
问题 I have below query that works fine. \App\Models\Membership\MembershipModel ::with(['Packages' => function($query){ $query->where('ExperienceID', \Auth::user()->ExperienceID) ; }]) ->get(); In this above query I applied filter and works fine . Issue comes when I add more relation table and filter don't work at all. \App\Models\Membership\MembershipModel ::with(['Packages' => function($query){ $query->where('ExperienceID', \Auth::user()->ExperienceID) ; }]) ->with('Packages.AssetTypes') ->get()

Mongodb string to date conversion

时光总嘲笑我的痴心妄想 提交于 2019-12-24 18:24:00
问题 Below is my sample mongodb collection { "_id" : ObjectId("57ed32f4070577ec56a56b9f"), "log_id" : "180308", "issue_id" : "108850", "author_key" : "priyadarshinim_contus", "timespent" : NumberLong(18000), "comment" : "Added charts in the dashboard page of the application.", "created_on" : "2017-08-16T18:22:04.816+0530", "updated_on" : "2017-08-16T18:22:04.816+0530", "started_on" : "2017-08-16T18:21:39.000+0530", "started_date" : "2017-08-02", "updated_date" : "2017-08-02", "role" : "PHP",

Import utf-8 headings Maatwebsite Laravel

怎甘沉沦 提交于 2019-12-24 17:08:26
问题 I'm using Maatwebsite in Laravel and it's very good option for excel works but I have one problem .. I have excel sheet with arabic heading, so when I import it , it converted to understand-less english character to fit array key .. So What is the solution for my problem? 回答1: I know it's too late, but for someone else that may have the same problem, you should change the value of "heading" key to "original" in "import" array of config/excel.php file.. 'import' => [ ... 'heading' => 'original

Import utf-8 headings Maatwebsite Laravel

别说谁变了你拦得住时间么 提交于 2019-12-24 17:08:11
问题 I'm using Maatwebsite in Laravel and it's very good option for excel works but I have one problem .. I have excel sheet with arabic heading, so when I import it , it converted to understand-less english character to fit array key .. So What is the solution for my problem? 回答1: I know it's too late, but for someone else that may have the same problem, you should change the value of "heading" key to "original" in "import" array of config/excel.php file.. 'import' => [ ... 'heading' => 'original

Laravel 5.2 Mocked file upload unit test fails

孤街浪徒 提交于 2019-12-24 16:44:06
问题 I've just upgraded from Laravel 5.1 to 5.2 and previously successful tests are now failing, with "Perhaps an exception was thrown?" There were 3 failures: 1) TRP\Nps\Tests\FileHandlerControllerTest::testCSVFileUploadImportsRecipients Invalid JSON was returned from the route. Perhaps an exception was thrown? /home/vagrant/Code/nps/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:354 /home/vagrant/Code/nps/vendor/laravel/framework/src/Illuminate

Laravel 5.1 mocking 'unique' validation rule

安稳与你 提交于 2019-12-24 15:14:19
问题 We are using the 'unique' rule for validation on the application, but for tests we're mocking the database layer through the use of repository pattern. Is there a way to mock the unique rule so that it doesn't attempt to check the database? I tried mocking Illuminate\Validation\Validator::validateUnique it doesn't work but since the method is protected. 回答1: unique rule, along with a few other rules (e.g. exists ) uses presence verifier to do validation checks. By default

Laravel 5 php artisan migrate does not work

人走茶凉 提交于 2019-12-24 15:09:52
问题 Im using Mac os x Yosemite 10.10 . I installed the lastest laravel version 5.1 . I set up Homestead and it has been running great. However, when I try to make a MySQL connection in my Laravel app, and am now experiencing errors when running php artisan migrate on my development machine. Following is the statement that I see when I run php artisan migrate. [PDOException] SQLSTATE[HY000] [2002] No such file or directory How can I solve this problem? When I get into VM, mysql works fine. But I

getRealPath returning false (Image Intervention and Laravel 5.1)

情到浓时终转凉″ 提交于 2019-12-24 13:37:23
问题 I'm having a problem while using the getRealPath function. $file = Input::file('archivo'); $img = Image::make($file->getRealPath()); I'm getting this exception: NotReadableException in AbstractDecoder.php line 302. Image Not Readable. I tried printing the value for $file->getRealPath() with dd() function and it prints false . Also I tried using dd(Input::hasFile( 'archivo' )) and that returned me true . I can't seem to find an answer, I have tried almost everything I think. So basically I

Laravel 5.1 consuming soap wsdl service using controller and model

主宰稳场 提交于 2019-12-24 12:44:33
问题 Currently I'm using php and nusoap and wanted to convert it to Laravel. When creating the soap calls I use data out of a mysql database. So I think I would need a model (to get my data) and a controller (to create request). EDIT: <?php namespace App\Http\Controllers; use Artisaninweb\SoapWrapper\Facades\SoapWrapper; class SoapController extends Controller { public function demo() { // Add a new service to the wrapper SoapWrapper::add(function ($service) { $service ->name('currency') ->wsdl(