hi i have 2 Database User And Massage .
every massage has tow user , one sender and one receiver.
and i want to Store sender and receiver user by its names.
i write this code and it have Error , what do you suggest?
code in message tabale :
public function up()
{
Schema::create('massage', function(Blueprint $table)
{
$table->increments('id');
$table->string('sender_user_name');
$table->string('receiver_user_name');
$table->string('tittle');
$table->text('body');
$table->timestamps();
$table->timestamp('published_at');
$table->foreign('sender_user_name')
->references('name')
->on('users')
->onDelete('cascade');
$table->foreign('receiver_user_name')
->references('name')
->on('users');
});
}
User tabel :
public function up()
{
Schema::create('users', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
}
Code for saving message ( Tittle , body , and Times insert in form ):
$input = $request->all();
$input['sender_user_name'] = Auth::user()->name;
Massage::create($input);
and this is My error :
ndefined property: Illuminate\Database\Eloquent\Relations\BelongsTo::$name (View: C:\xampp\htdocs\massage\resources\views\articles\index.blade.php)
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1EHm0BY
via IFTTT
Aucun commentaire:
Enregistrer un commentaire