laravel-5

Laravel 5: override the default view for Registration page

北城以北 提交于 2021-02-20 06:24:07
问题 I want to change the auth process to use another view template. E.g. instead of resources/views/auth/register.blade.php it shall be used resources/views/register.blade.php . But I struggle to find the code where this view is called. The only place I found was in app/Services/Register but only if the validators fails. I need the place when the view is called per default. 回答1: In AuthController, you can overwrite the method getRegister() method like this : public function getRegister() { return

Laravel 5.6 Method Illuminate\Database\Query\Builder::createToken does not exist

痞子三分冷 提交于 2021-02-20 03:54:31
问题 I am trying to create API authentication using Passport but I can not seem to create a token when a user is being registered using createToken (). I have already checked I have included HasApiTokens but still gives same error. ERROR Method Illuminate\Database\Query\Builder::createToken does not exist App\User namespace App; use Laravel\Passport\HasApiTokens; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable {

Laravel eloquent withCount() supposed to be slower than just with()

孤街醉人 提交于 2021-02-19 07:51:25
问题 So the reason i ask this is that in my current app withCount() almost triples the response time vs just fetching all the data for the relationship via with() and just getting the length from the frontend (javascript). I thought the point of using withCount() was to speed up the query but maybe i'm wrong? for example: courseSession::where('id', '>=', 1) ->where('id', '<=', 320) ->withCount('enrollments') ->get(); averages around 900ms response (debugbar shows this as a single DB call) but

Laravel 5 + Eloquent toJson/toArray causes Strange Segmentation Faults

﹥>﹥吖頭↗ 提交于 2021-02-19 02:28:51
问题 I hate to be answering my own question, so maybe you can help me find what fixed this. I have some eloquent models which belongTo each-other, and I set them up via association like this. It's all normal stuff. This process unfortunately causes $device to work erratically. Below you can see individual values are accessible but any form of jsonification destroys the server without error. $device = $truck->device; if(is_null($device) || empty($device)) { $device = new Devices; } $device->truck()

Laravel PHPUnit mock Request

泄露秘密 提交于 2021-02-19 02:04:12
问题 I'm doing a PHPUnit on my controller and I can't seem to mock the Request right. Here's the Controller: use Illuminate\Http\Request; public function insert(Request $request) { // ... some codes here if ($request->has('username')) { $userEmail = $request->get('username'); } else if ($request->has('email')) { $userEmail = $request->get('email'); } // ... some codes here } Then on the unit test, public function testIndex() { // ... some codes here $requestParams = [ 'username' => 'test', 'email'

Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) Laravel

寵の児 提交于 2021-02-18 22:12:45
问题 I have a problem with Laravel . after restart my system, My project will not run !!! I run with php artisan serv , but I have below messages in console : [Tue Jul 3 14:31:35 2018] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /laravel-projects/blog/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 122 [Tue Jul 3 14:31:35 2018] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried

How to display image from aws s3 in blade laravel 5.2

两盒软妹~` 提交于 2021-02-18 17:10:51
问题 I have created a method for getting the data(image file) from aws S3 like this : public static function getImage ($imagePath) { if(Storage::exists($imagePath)) { return Storage::disk('s3')->get($imagePath); }else { return 'No Image'; } } I'm sure that those image is exist on the aws, so there is no problem with that. And then I use above method as the src in my blade view like this : {!!Html::image(getImage($myPath),'logo',['width'=>60,'height'=>55])!!} $myPath here already point to the

Mixed Content (laravel)

半城伤御伤魂 提交于 2021-02-18 10:48:27
问题 I get the following error (on every page) app.js:703 Mixed Content: The page at 'https://sitename.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://sitename.com/index.php/getMessages'. This content should also be served over HTTPS. The site is build with Laravel. Is there anybody who knows how to fix this error? 回答1: In my case it's because I wasn't aware that the asset() function didn't handle https automatically (as pointed out by frankfurt-laravel's

User Class not found in Laravel 5

亡梦爱人 提交于 2021-02-17 03:05:50
问题 I have got the following Problem. I have just upgraded to Laravel 5 from 4.2 but my UserController which I first just copied to the new Controllers folder does not work. It always tells me that it does not fiend the User Model. My Code looked like the following when I copied it: UserController.php <?php use App\Transformer\UserTransformer; class UserController extends ApiController { public function index() { App::abort(403, 'This is not allowed'); } public function show($id) { $user = User:

User Class not found in Laravel 5

风流意气都作罢 提交于 2021-02-17 03:04:09
问题 I have got the following Problem. I have just upgraded to Laravel 5 from 4.2 but my UserController which I first just copied to the new Controllers folder does not work. It always tells me that it does not fiend the User Model. My Code looked like the following when I copied it: UserController.php <?php use App\Transformer\UserTransformer; class UserController extends ApiController { public function index() { App::abort(403, 'This is not allowed'); } public function show($id) { $user = User: