laravel-5.3

Relationship not being passed to notification?

♀尐吖头ヾ 提交于 2020-03-06 04:38:26
问题 I created a notification that I am passing a model to: class NewMessage extends Notification implements ShouldQueue { use Queueable; protected $message; public function __construct(Message $message) { $this->message = $message; } public function via() { return ['database']; } public function toArray() { Log::info($this->message); return [ 'message_id' => $this->message->id, ]; } } And this is how I call the notification: $message = Message::where('user_id', Auth::user()->id) ->where('message

How to use variables in routes in laravel?

眉间皱痕 提交于 2020-03-02 10:18:57
问题 I'm trying to build a application in laravel 5.3 in which I get the variable from request method and then trying to pass that variable in a redirect to the routes. I want to use this variable in my view so that I can be able to display the value of variable. I'm currently doing this: In my controller I'm getting the request like this: public function register(Request $request) { $data = request->only('xyz','abc'); // Do some coding . . $member['xyz'] = $data['xyz']; $member['abc'] = $data[

How to use variables in routes in laravel?

删除回忆录丶 提交于 2020-03-02 10:16:28
问题 I'm trying to build a application in laravel 5.3 in which I get the variable from request method and then trying to pass that variable in a redirect to the routes. I want to use this variable in my view so that I can be able to display the value of variable. I'm currently doing this: In my controller I'm getting the request like this: public function register(Request $request) { $data = request->only('xyz','abc'); // Do some coding . . $member['xyz'] = $data['xyz']; $member['abc'] = $data[

Laravel auth login not working

穿精又带淫゛_ 提交于 2020-02-25 04:37:06
问题 I am new to laravel, I'm working on a Laravel authentication system, and while registration works, but login doesn't do anything. UserController.php class UserController extends Controller { public function postSignUp(Request $request) { $email = $request['email']; $first_name = $request['first_name']; $password = bcrypt($request['password']); $user = new User; $user->email = $request->email; $user->first_name = $request->first_name; $user->password = bcrypt($request->password); $user->save()

count relation of relation in laravel

血红的双手。 提交于 2020-02-15 10:02:43
问题 Suppose I have a Conversation model like this : class Conversation extends Model { public function questions (){ return $this->hasMany('App\Question','conversation_id','conversation_id'); } public function category () { return $this->belongsTo('App\Category', 'cat', 'cat_id'); } } And a Question model like this: class Question extends Model { public function conversation () { return $this->belongsTo('App\Conversation', 'conversation_id', 'conversation_id'); } } As you can see there is a

Laravel how to check validate unique table two field

帅比萌擦擦* 提交于 2020-02-02 12:59:47
问题 I have tableA that there are 2 field 1. song_id 2. playlist_id I want to check laravel validate unique func example: I have inserted data id => 1 song_id => 2 playlist_id => 34 then I have to insert data again I want to check that if playlist_id => 34 already inserted song_id = 2 show message "already insert" but if playlist_id => 34 insert song_id = 3 allow insert thank you for your help! 回答1: This is the rule that need to apply. Tested with sample data and it works as desired. use

How display image in laravel 5.3

冷暖自知 提交于 2020-02-02 04:53:50
问题 I store image in public folder now i want to display the image i give the path but image not show any one help me whats the wrong in my code My image complete path is public/admin/product <img src="public/admin/product/<?php echo $productr['image']; ?>" height="30px" width="30px"> 回答1: Laravel view files blade.php supports {{}} tags to display values. {{ $valueToBeDisplayed }} In your case, you can do like <img src="/admin/product/{{ $product['image'] }}" height="30px" width="30px" />

Error Field doesn't have a default value in laravel 5.3

房东的猫 提交于 2020-01-30 06:46:08
问题 I have no problem in Laravel 5.2 but in Laravel 5.3 after create migration for user model, It shows me following error: SQLSTATE[HY000]: General error: 1364 Field 'family' doesn't have a default value !!! In Model user: protected $fillable = [ 'name', 'email', 'password', 'family', 'mobile', 'address', 'status' ]; In Migration: Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('family'); $table->string('mobile')->unique();

post 500 (internal server error) ajax though using csrf token in laravel

天大地大妈咪最大 提交于 2020-01-17 14:35:14
问题 Though I am using {{ csrf_field() }} in my html file still got POST http://localhost:8000/add_user 500 (Internal Server Error) here is my code $.ajax({ url:"/add_user", type: 'post', data: {_token : token, user_type_id : user_type_id, full_name : full_name, email : email, password : password, username : username, date : date}, success:function(msg){ $("#report").load(location.href + " #report"); } }); 回答1: you can do this with csrf token $.ajax({ type: "POST", url: "url/update", dataType:

How can I run slider in vue component?

心不动则不痛 提交于 2020-01-17 07:42:10
问题 My view like this : @foreach($leagues as $league) <a @click="$refs.leagues.changeLeague({{ $league->id }})"> {{ $league->name }} </a> @endforeach ... <top-league class="slick" league-id="{{ $league_id }}" ref="leagues"></top-league> 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.id+'/'+item.name" :style="{backgroundImage: 'url(' +