laravel-5.3

Laravel 5.3 - TokenMismatchException in VerifyCsrfToken.php line 68:

时光总嘲笑我的痴心妄想 提交于 2019-12-01 05:38:48
When I log in to my app, and immediately go back when I enter it, and then try to log out, I get the error from the title, how can I fix that? I was facing same issue with laravel 5.4 .. and then following command works for me :) chmod 777 storage/framework/sessions/ before this, it was chmod 775 storage/framework/sessions/ ... hence I was facing the issue... Happy coding From Laravel 5.3 docs The Auth::routes method now registers a POST route for /logout instead of a GET route. This prevents other web applications from logging your users out of your application. To upgrade, you should either

PostTooLargeException in ValidatePostSize.php line 22 laravel

假装没事ソ 提交于 2019-12-01 05:23:13
I am trying to upload a form containing images too. When I submit it. it shows this error PostTooLargeException in ValidatePostSize.php line 22: How do I resolve this issue? Check the following parameters in your php.ini file. I've had this issue on several occasions and it's usually because the max_file_size is set to 2M by default. max_file_size upload_max_filesize post_max_size **Edit I was asked how to validate file size using the validate method in Laravel before the file is sent to PHP and alerting the user of the large file. You can and this is how: 1. Create an error alert for the

Laravel file upload API using Postman

荒凉一梦 提交于 2019-12-01 04:18:15
I have the following code in my controller: public function upload(Request $request) { $files = $request->file('uploads'); if(!empty($files)) { foreach($files as $file) { Storage::put($file-getClientOriginalName(),file_get_contents($file)); } } Which is called via an api.php in routes : Route::post('/upload', [ 'uses' => 'UploadController@upload' ]); I am using postman to test my application. Header: Body: Raw: POST /scotic/public/api/upload HTTP/1.1 Host: 127.0.0.1:80 Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW Cache-Control: no-cache Postman-Token:

laravel passport custom password column

纵然是瞬间 提交于 2019-12-01 04:09:47
问题 How can I use Laravel's Passport package to authenticate a different password column. If i want to authenticate from a different 'username' column, it can be done with the following code: public function findForPassport($username) { return $this->where('id', $username)->first(); } It will take Id, as the column. What if I want to use a different 'password' column. A column in the table with a different name such as 'uid_token'. 回答1: There's a method the Passport/Bridge asks for called

Laravel 5.3 - TokenMismatchException in VerifyCsrfToken.php line 68:

空扰寡人 提交于 2019-12-01 02:46:42
问题 When I log in to my app, and immediately go back when I enter it, and then try to log out, I get the error from the title, how can I fix that? 回答1: I was facing same issue with laravel 5.4 .. and then following command works for me :) chmod 777 storage/framework/sessions/ before this, it was chmod 775 storage/framework/sessions/ ... hence I was facing the issue... Happy coding 回答2: From Laravel 5.3 docs The Auth::routes method now registers a POST route for /logout instead of a GET route.

Laravel file upload API using Postman

倖福魔咒の 提交于 2019-12-01 02:00:31
问题 I have the following code in my controller: public function upload(Request $request) { $files = $request->file('uploads'); if(!empty($files)) { foreach($files as $file) { Storage::put($file-getClientOriginalName(),file_get_contents($file)); } } Which is called via an api.php in routes : Route::post('/upload', [ 'uses' => 'UploadController@upload' ]); I am using postman to test my application. Header: Body: Raw: POST /scotic/public/api/upload HTTP/1.1 Host: 127.0.0.1:80 Content-Type: multipart

How can I use db transaction in laravel?

情到浓时终转凉″ 提交于 2019-12-01 01:01:00
I try this : public function destroy($id) { DB::beginTransaction(); try { $product = $this->product_repository->find($id); $result = $product->categories()->detach(); if($result) { list($status,$instance) = $this->product_repository->delete($id); } DB::commit(); return ['status'=>true,'data'=>$status]; } catch (\Exception $e) { DB::rollback(); return ['status'=>false, 'message'=>$e->getMessage()]; } } If the code executed, $this->product_repository->delete($id) not work / not success delete. But this : $product->categories()->detach(); , it works / success deleted. How to if delete product

How to create custom controller in Laravel Voyager

↘锁芯ラ 提交于 2019-11-30 15:51:32
I am very much new in Voyager. I have got all the controllers inside TCG\\Voyager\\Http\\Controllers while installing Voyager but didn't find other controllers those I have created using BREAD. Besides that I want to create custom controller in my Voyager admin panel inside App\\Http\\Controllers\\Voyager . I also follow the steps of Voyager tutorial in Youtube for making custom controller, but can't create. Any body help please ? In your config\voyager.php file add your namespace: 'controllers' => [ 'namespace' => 'App\Http\Controllers\Back', ], Then publish voyageres controllers to your

Using Vue.js in Laravel 5.3

孤者浪人 提交于 2019-11-30 11:55:52
问题 In Laravel projects prior to 5.3 I've utilised Vue.js using the script tag like this: <script type="text/javascript" src="../js/vue.js"></script> I would then create a Vue instance specific for that page like this: <script> new Vue({ el: '#app', data: { message: 'Hello Vue.js!' } }); </script> and then bind it to the relevant div#id in my HTML. Now, in Laravel 5.3 Vue.js comes bundled and I am fully aware that I can use components as described in the docs by using gulp/elixir, however, my

Laravel 5.3 Creating Models Returns “Field doesn't have a default value”

那年仲夏 提交于 2019-11-30 11:33:57
I'm using Laravel and Eloquent for two years and today I've decided to install a fresh Laravel 5.3 and try something with it. I used an old database schema of mine and created my models, defined fillable columns. This is what my Page model looks like: <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Page extends Model { /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'language', 'title', 'slug', 'url', 'description', 'tags', 'wireframe', 'order', 'is_active' ]; public function menus() { return $this->belongsToMany(Menu::class);