laravel-5.3

Why the deleted data still appear in the interface?

大憨熊 提交于 2019-11-29 18:08:16
Look here : When I click button delete, data deleted still appear in the interface. I look at the table in the database, the data is erased. Data can be lost if I run this: php artisan cache:clear on git bash. How without running the command, data can be erased? UPDATE My controller is like this : public function deleteAccount(Request $request) { $id_account = $request->input('id_account'); try{ if($this->user_service->deleteAccount($id_account)) { $status='success'; }else { $status = 'failed'; } return redirect('member/profile/setting/account')->with('status',$status); }catch (\Exception

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

自闭症网瘾萝莉.ら 提交于 2019-11-29 17:21:02
问题 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',

How to create query with twice a connection to a table in Laravel 5.3?

a 夏天 提交于 2019-11-29 15:55:45
I need get two city names with one query: For example: City table: +---------+----------+ | Pana | Name | +---------+----------+ | THR | Tehran | | LON | London | +---------+----------+ In Model: from_city is THR and to_city is LON public function scopePrintQuery($query, $id) { $join = $query -> join('cities', 'cities.pana', 'flights.from_city') -> join('cities', 'cities.pana', 'flights.to_city') -> where('flights.id', $id) ->get([ 'flights.*', 'cities.name as from_city' ??? for to_city? ]); return $join; } Now, I need get from_city name and to_city name in this query. The query does not work

How to remove an item from session array in laravel

瘦欲@ 提交于 2019-11-29 15:27:13
Here is the problem I have a session session('products') this is actually an array that contains id session('products') array:4 [▼ 0 => "1" 1 => "2" 2 => "4" 3 => "1" ] Now I want to delete lets say 4 How do I do that? I tried method session()->pull($product, 'products'); But it didn't work! Other solution session()->forget('products', $product); it also didn't work Albert221 You AFAIR have to firstly retrieve whole array, edit it and then set it again. If you want to delete by product ID, which is as I assume an array value, you can use this: PHP array delete by value (not key) $products =

Laravel Eloquent Union query

可紊 提交于 2019-11-29 14:10:53
So I have the following query: $a = Model::where('code', '=', $code) ->where('col_a', '=' , 1) ->orderBy(DB::raw('FIELD(layout, "normal", "split", "flip", "double-faced", "") ASC, layout')) $b = Model::where('code', '=', $code) ->where('col_b', '=' , 1) ->orderBy(DB::raw('FIELD(layout, "normal", "split", "flip", "double-faced", "") ASC, layout')) $a->union($b)->get(); No sorting is happening when I 'orderBy()' first and then union. When I do query '$a' or '$b' individually the 'orderBy()' works fine. When I do it in the following way 'orderBy()' happens as a whole. $a->union($b) ->orderBy(DB:

How to change storage path in laravel 5.3 to public?

女生的网名这么多〃 提交于 2019-11-29 12:35:29
问题 In laravel 5.3 , if I upload a file from a form, it will be stored in own storage directory. Then I should create a symlink to that storage path in public path. I can't use creating symlinks on my system because of the limitation. How can I upload files directly to public/uploads instead of storage/app/uploads ? I tried to set the path in AppServiceProvider.php but it doesn't work. public function register() { //not working: $this->app->useStoragePath( $this->app->basePath() . "/upload"); /

Laravel Auth::attempt() returns false

荒凉一梦 提交于 2019-11-29 09:50:57
I am a home hobbyist and am studying Laravel, currently in version 5.3 . I am using a Mac, neither homestead nor vagrant . I'm currently working on a website that uses a login and a register system to create users. I've used php artisan migrate to manipulate my database locally. As listed below, it has three fields, namely: Email Username Password I have a User model (users.php): <?php namespace blog; use Illuminate\Notifications\Notifiable; use Illuminate\Database\Eloquent\Model; use Illuminate\Contracts\Auth\Authenticatable; class User extends Model implements Authenticatable { use

Multiple Authentication in Laravel 5.3

泄露秘密 提交于 2019-11-29 05:14:27
How to setup multiple authentication in Laravel 5.3 for two different tables(Users and Admin). By default Laravel has User Model. Gadzhev Looks like you need to implements roles. You can use the default Laravel User Model and will need to create a Role Model: User Model ... public function role() { return $this->belongsToMany('App\User', 'user_roles', 'role_id', 'user_id'); } public function inRole($role) { return (bool) $this->role()->where('name', '=', $role)->count(); } ... Role Model ... public function users() { return $this->belongsToMany('App\Role', 'user_roles', 'user_id', 'role_id');

Laravel 5.3 - Single Notification for User Collection (followers)

给你一囗甜甜゛ 提交于 2019-11-29 00:45:38
问题 When I have a single notifiable user, a single entry in the notifications table is inserted, along with a mail / sms sent which is perfectly working via channels. The issue is when I have a user collection, a list of 1k users following me, and I post an update. Here is what happens when using the Notifiable trait as suggested for multi-user case: 1k mails / sms sent (issue is not here) 1k notification entries added to the DB's notifications table It seems that adding 1k notifications to the

Laravel 5.3 - How to log all queries on a page?

喜夏-厌秋 提交于 2019-11-28 22:45:02
问题 My team and I are working on a rather big project. There's queries going on everywhere - in controllers, in view composers in views (lazy loading) and probably in some other services as well. It's getting hard to keep a track of it all and the page load speed is fairly slow at the moment. Where would I put \DB::enableQueryLog() and \DB::getQueryLog() to log ALL the queries and dump them? Basically I'm looking for some place in code that happens before any of the queries happen (to put