laravel-5.2

Request Errors not accessible in blade (Laravel 5.2)

↘锁芯ラ 提交于 2019-12-05 19:44:25
问题 It had been many months since I'm using laravel but never faced such problem. I have made a simple Request class to validate the the update user request which works fine if validation rules are followed. If validation rule fails we should come back to the previous page and display all errors in html. According to me I have written everything correctly as I used to write in other applications but the $errors seems to be inaccessible in blade Following are my required code snippets to debug:

Laravel Resource destroy via ajax

断了今生、忘了曾经 提交于 2019-12-05 18:25:06
Can I use resource via ajax? I have this resource Route::resource('dashboard', 'DashBoardController'); js file $.ajax({ type: 'delete', dataType: 'json', data: {id:id}, url: " {!! route('dashboard.destroy') !!} ", success: function (data) { // } }); but I receive, NotFoundHttpException in RouteCollection.php line 161: Bagaskara Wisnu Gunawan A destroy method is using a DELETE request , but it actually uses POST request within an _method as parameter, so your javascript section should looks like this: $.ajax({ type: 'POST', dataType: 'json', data: { id: id, _method: 'DELETE' }, url: "{!! route(

laravel fcm push notification with brozot/Laravel-FCM not working on ios but working fine with android

∥☆過路亽.° 提交于 2019-12-05 18:16:56
Even ios can get notification from fcm console. Controller function : public function push(Request $request) { $validator = Validator::make($request->all(), [ 'title' = > 'required', 'body' = > 'required', 'token' = > 'required', 'type' = > 'required', 'id' = > 'required', ]); if ($validator->fails()) { $this->throwValidationException( $request, $validator ); } $title = $request['title']; $body = $request['body']; $type = $request['type']; $id = $request['id']; $dataarray = array( "id" = >$id, "type" = >$type, 'title' = >$title, 'body' = >$body, 'image' = >'321451_v2.jpg', ); $token = $request

how to use delete method in route in laravel 5.2

我的梦境 提交于 2019-12-05 16:24:31
I want to use delete route in my laravel project. like and want to send route from href of a anchor tag. is it possible to use delete method in route from "href" of anchor tag Route::delete('/news/{id}', 'NewsController@destroy'); You can't use anchor tag with href to send the request to delete. You need a form todo so. With a method DELETE since in form we have only get and post so create a hidden field with name _method and value DELETE Create form similar to this : <form action="news/id" method="post"> <input type="hidden" name="token" value="{{csrf_token}}" > <input type="hidden" name="

Laravel overriding EloquentUserProvider to change password field name in validateCredentials()

放肆的年华 提交于 2019-12-05 15:28:20
I've managed to change the password field in the code through overriding various classes/methods. But I after trying to override EloquentUserProvider and it's validateCredentials() method I keep getting an error - ErrorException in AuthUserProvider.php line 15: Argument 1 passed to App\Providers\AuthUserProvider::__construct() must be an instance of App\Helpers\Sha1Hasher, instance of Illuminate\Foundation\Application given I created an override App\Providers\AuthUserProvider.php - namespace App\Providers; use Illuminate\Contracts\Auth\Authenticatable as UserContract; use App\Helpers

Dingo API remove “data” envelope

…衆ロ難τιáo~ 提交于 2019-12-05 15:08:45
问题 is it there an easy way to remove the "data" envelope from the Dingo API response. When I use this Transformer to transform user models: class UserTransformer extends EloquentModelTransformer { /** * List of resources possible to include * * @var array */ protected $availableIncludes = [ 'roles' ]; protected $defaultIncludes = [ 'roles' ]; public function transform($model) { if(! $model instanceof User) throw new InvalidArgumentException($model); return [ 'id' => $model->id, 'name' => $model-

Laravel 5 authenticate users through external API

心不动则不痛 提交于 2019-12-05 13:32:59
I'd like to know is it possible to extend the built-in authentication to use an external API to authenticate a user? I'm a Laravel newbie, so I'd appreciate your help. I'm making a custom app in Laravel 5.2 for my client, but I don't a direct access to their database server and I can only call their API to get users' details. Thanks. If I understood correctly you want to log users from APIs like facebook, twitter or github for example ? If that's so you need to use a laravel package named Socialite, here is the link to download and use it : https://github.com/laravel/socialite run on your

Best design practice to implement routes and controllers for a RESTFul Laravel app

三世轮回 提交于 2019-12-05 13:23:27
I am developing an application with Laravel 5.2, it has to be implemented RESTFUL. It is also very easy to implement RESTful resources in Laravel. for example for getting all categories in json format in routes we just have to add Route::resource('category', 'CategoryController'); and then in the CategoryController we are going to have this for returning a JSON object of all categories: class CategoryController extends Controller public function index() { $categories = Category::all(); return view('category.index', ['categories' => $categories]); } the the mydomain.com\category will be mapped

Using a Laravel model method in an Eloquent query

僤鯓⒐⒋嵵緔 提交于 2019-12-05 10:44:48
This is for Laravel 5.2. I have a method defined as follows in my Users model: public function name() { return "$this->name_first $this->name_last"; } I'm trying to figure out how to use that as part of a query, but it seems like it isn't possible for a somewhat obvious reason: the database doesn't know anything about the method and that makes perfect sense. However, the concept of what I'm trying to achieve makes sense in certain contexts, so I'm trying to see if there's a way to accomplish it naturally in Eloquent. This doesn't work, but it represents what I'm trying to accomplish: public

Conflict database when Multiple Laravel Projects on single machine or laravel not reading .env file

别说谁变了你拦得住时间么 提交于 2019-12-05 10:27:14
I am using xampp on windows 10. I have multiple laravel 5.2 projects on this machine. When I am executing Project 1 it gives me the error that database_project_1.table_of_project_2 table or view do not exist, but the table table_of_project_2 is existing in the database_project_2 . This issue comes rarely. Below is the Project 1 .env file APP_ENV=local APP_DEBUG=true APP_KEY=base64:ratSluNv930gb3wp1UOabW6Ze3jEJn3ixtTX/wgqYZc= APP_URL=http://project-1.dev/ DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=database_project_1 DB_USERNAME=root DB_PASSWORD=j@yshr33r@m Below is the