laravel-5.5

Json Assert Fails Laravel 5.5

血红的双手。 提交于 2020-04-17 22:11:15
问题 I am making a flash cards app with laravel 5.5 So I am trying to make the first tests but I can't make it pass. Failed asserting that an array has the subset Array &0 ( 'data' => Array &1 ( 'id' => 2020 ) ). --- Expected +++ Actual @@ @@ - [data] => Array - ( - [id] => 2020 - ) - /Users/marcosantana/devel/cards/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:290 /Users/marcosantana/devel/cards/tests/Unit/CardTest.php:26 FAILURES! Tests: 1, Assertions: 1, Failures:

Laravel : Class controller does not exist

 ̄綄美尐妖づ 提交于 2020-04-12 19:56:12
问题 I have created a simple controller and define a function. But when i run this it returns an error that controller does not exist. In my web.php assign a route. <?php Route::get('/', function () { return view('front.welcome'); }); Route::get('plan','PlanController@PlanActivity')->name('plan'); On otherside in my controller my code: <?php namespace App\Http\Controllers\Front; use App\Http\Controllers\Controller as BaseController; use Illuminate\Http\Request; class PlanController extends

Laravel : Class controller does not exist

和自甴很熟 提交于 2020-04-12 19:54:30
问题 I have created a simple controller and define a function. But when i run this it returns an error that controller does not exist. In my web.php assign a route. <?php Route::get('/', function () { return view('front.welcome'); }); Route::get('plan','PlanController@PlanActivity')->name('plan'); On otherside in my controller my code: <?php namespace App\Http\Controllers\Front; use App\Http\Controllers\Controller as BaseController; use Illuminate\Http\Request; class PlanController extends

Laravel 5.5 : How to define global variable that can be used in all controllers ?

浪尽此生 提交于 2020-04-11 05:57:09
问题 Hello Developers & Coders , My question is How to define a global variable , that can be used in all controllers in Laravel ? I have defined one variable $company in AppServiceProviders's boot method - that im using in all blade views , but I can not use it in controllers file , it gives error , undefined variable $company class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { View::share('key', 'value');

Laravel 5.5 : How to define global variable that can be used in all controllers ?

给你一囗甜甜゛ 提交于 2020-04-11 05:57:06
问题 Hello Developers & Coders , My question is How to define a global variable , that can be used in all controllers in Laravel ? I have defined one variable $company in AppServiceProviders's boot method - that im using in all blade views , but I can not use it in controllers file , it gives error , undefined variable $company class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { View::share('key', 'value');

Laravel DB::rollback() doesn't work for transaction processes

随声附和 提交于 2020-03-23 12:37:57
问题 First off my engine is innoDB and I already tried the following on mySQL: BEGIN; INSERT INTO `tbl_users`(...) VALUES (...) ROLLBACK(); And it works fine, meaning the problem wasn't in my mysql config. But when I tried this on my Laravel Model: public static function addNew($request, $department_id) { $result = array(); $now = Carbon::now(); DB::beginTransaction(); //Checking for existing Order to set appropriate starting ID $result = DB::select(" SELECT COUNT(`id`) AS 'count' FROM `tbl

How i can return a customized response in a FormRequest class in Laravel 5.5?

风格不统一 提交于 2020-03-18 04:00:30
问题 I am making an API and i want return the array of errors with a format as the one that $validator->errors(); generates when i validate the request by the manual way. But i cant manipulate the response. I wanna find thhe correct way to make it. This could be done in Laravel 5.4 with the formatErrors method and including the Illuminate\Contracts\Validation\Validator class in the FormRequest class but for version 5.5 it does not work. I do not know how to do it. This is my Controller: <?php

Use sessions in laravel APIs

风格不统一 提交于 2020-02-03 09:21:48
问题 To create a Two-factor SMS verification in larvel 5.5 and via dingo package, I follow this Simplified workflow: First check isTwoFactorActive is true or false in your login function if its true send SMS and give the response to get SMS code which is received. If its false directly return token. Route::post('auth/login', function () { $credentials = Input::only('email', 'password'); if ( ! $token = JWTAuth::attempt($credentials) ) { // return the 401 response return Response::json(['error' =>

Use sessions in laravel APIs

送分小仙女□ 提交于 2020-02-03 09:19:10
问题 To create a Two-factor SMS verification in larvel 5.5 and via dingo package, I follow this Simplified workflow: First check isTwoFactorActive is true or false in your login function if its true send SMS and give the response to get SMS code which is received. If its false directly return token. Route::post('auth/login', function () { $credentials = Input::only('email', 'password'); if ( ! $token = JWTAuth::attempt($credentials) ) { // return the 401 response return Response::json(['error' =>

How Can I add a user of type jobber to another user Favorite List using Laravel

為{幸葍}努か 提交于 2020-01-25 06:54:40
问题 I am working on the add to favorites and view favorites list functionality on my website. I have managed to create 2 tables A users tables with id, name, surname, photo, type and email A favorites tables with id, user_id, favoriteable_id, created_at and updated_at I was trying to implement it in such a way that when a user, who is connected to his account clicks on the add to favorites button, It will add the user selected on his list of favorites. I tried doing it this way but it didn't