laravel-5.3

Laravel 5.3 db:seed command simply doesn't work

杀马特。学长 韩版系。学妹 提交于 2020-01-01 01:26:06
问题 I do everything by-the-book: Installed fresh Laravel 5.3.9 app (all my non-fresh apps produce the same error) run php artisan make:auth create migrations for a new table `php artisan make:migration create_quotations_table --create=quotations Schema::create('quotations', function (Blueprint $table) { $table->increments('id'); $table->string('text'); // my problem persists even with the below two columns commented out $table->integer('creator_id')->unsigned()->index('creator_id'); $table-

Laravel 5.3 db:seed command simply doesn't work

拈花ヽ惹草 提交于 2020-01-01 01:26:05
问题 I do everything by-the-book: Installed fresh Laravel 5.3.9 app (all my non-fresh apps produce the same error) run php artisan make:auth create migrations for a new table `php artisan make:migration create_quotations_table --create=quotations Schema::create('quotations', function (Blueprint $table) { $table->increments('id'); $table->string('text'); // my problem persists even with the below two columns commented out $table->integer('creator_id')->unsigned()->index('creator_id'); $table-

How to make a Trait in Laravel

倖福魔咒の 提交于 2019-12-31 10:33:13
问题 Where to make the file if i want to use this trait on my Models How should this file look like if i want to have this trait inside: trait FormatDates { protected $newDateFormat = 'd.m.Y H:i'; // save the date in UTC format in DB table public function setCreatedAtAttribute($date){ $this->attributes['created_at'] = Carbon::parse($date); } // convert the UTC format to my format public function getCreatedAtAttribute($date){ return Carbon::parse($date)->format($this->newDateFormat); } // save the

How can I make sub query in laravel eloquent?

别等时光非礼了梦想. 提交于 2019-12-31 05:26:10
问题 When I use db raw, it works My query is using db raw like this : $products = DB::select(DB::raw('SELECT * FROM ( SELECT a.*, b.name AS store_name, b.address FROM products a JOIN stores b ON b.id = a.store_id WHERE a.category_id = '.$category_id.' ORDER BY a.total_sold DESC, a.updated_at DESC LIMIT '.$num.' ) AS product GROUP BY store_id')); It works. But I want to change it use laravel eloquent I try like this : $products = Product::where('category_id', '=', $category_id) ->with('store') -

Why the slider does not work when I click another tab on vue component?

戏子无情 提交于 2019-12-31 05:20:08
问题 My view like this : @foreach($leagues as $league) <a data-toggle="tab" @click="$refs.leagues.changeLeague({{ $league->id }})"> {{ $league->name }} </a> @endforeach ... <div class="tab-pane active"> <top-league class="slick" league-id="{{ $league_id }}" ref="leagues"></top-league> </div> My top league component vue like this : <template> <div class="row"> <div class="col-md-3" v-for="item in items"> <div class="panel panel-default"> <div class="panel-image"> <a :href="baseUrl+'/leagues/'+item

Laravel returning a blank page only on certain routes

僤鯓⒐⒋嵵緔 提交于 2019-12-30 09:59:08
问题 I'm having an issue where a route is returning a blank page. I am using Homestead as my dev environment and I'm unsure how to debug. The /storage/logs/laravel ... isn't returning any exceptions when I visit the white page. web.php (where it's failing): Route::get('/clinic/register', 'ClinicController@register'); Controller.php: public function register() { return view('clinic.register', ['specialisms' => Specialism::pluck('specialism', 'id')]); } Yet when I visit /clinic/register I am shown a

laravel errno 150 foreign key constraint is incorrectly formed

北慕城南 提交于 2019-12-29 04:43:07
问题 Can anybody help me to solve this problem? There are 3 tables with 2 foreign keys: Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); Schema::create('firms', function (Blueprint $table) { $table->increments('id'); $table->string('title')->nullable(); $table->integer('user_id')->unsigned()->nullable(); $table->foreign('user_id')-

Laravel 5.3 Login redirect to different pages for multiple users

人走茶凉 提交于 2019-12-28 18:04:40
问题 I have Laravel 5.3 with three different types of users. I want them to be redirected to different dashboard pages after logging in. For example: user -> login -> user-dashboard admin -> login -> admin-dashboard I have created a middleware called CheckRole : public function handle($request, Closure $next) { if($request->user() === null) { return response("Insufficient Permissions" , 401); } $actions = $request->route()->getAction(); $roles = isset($actions['roles']) ? $actions['roles'] : null;

Convertise Data in Pdf in laravel 5.3

筅森魡賤 提交于 2019-12-25 19:15:38
问题 I want to convert data in pdf using laravel 5.3. I have tried using fpdf. but i did not get any success. how to convert data in pdf using laravel 5.3. 回答1: This is the code which which I used in my ReportsController and will help you to convert your data into pdf public function getDownloadPDF($id){ $objReports=Walkthrough::find($id); $objReports=DB::table('walkthroughs') ->join('users','users.id','=','walkthroughs.user_id') ->select('users.first_name as FirstName','users.last_name as

How can I upload image to different project on the laravel?

六眼飞鱼酱① 提交于 2019-12-25 18:12:57
问题 I have two project or url First url like this : http://myshop.dev/ Second url like this : http://backend.myshop.dev/ If the second url, I upload image it will save the image file here : http://myshop.dev/img/image1.jpg Both projects use the same database My code to upload image on the second project like this : public function __construct(...) { ... $this->path = './img'; } ... public function store(...) { ... $filename = Input::file('photo')->getClientOriginalName(); ... Input::file('photo')