Last active
March 8, 2017 19:53
-
-
Save segun6060/de4952a4f96197a93de349d81e5f6bee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Message extends Model | |
{ | |
public function user() | |
{ | |
return $this->belongsTo('App\User','id'); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function index() | |
{ | |
$user = User::has('message')->get(); | |
$user = User::has('collector')->get(); | |
return view('home', $user)->with('user', $user); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function up() | |
{ | |
Schema::create('messages', function (Blueprint $table) { | |
$table->increments('id'); | |
$table->integer('userid'); | |
$table->string('name'); | |
$table->string('amount'); | |
$table->string('acname'); | |
$table->string('bname');; | |
$table->string('acnumber'); | |
$table->string('actype'); | |
$table->string('phone'); | |
$table->timestamps(); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Notifications\Notifiable; | |
use Illuminate\Foundation\Auth\User as Authenticatable; | |
class User extends Authenticatable | |
{ | |
use Notifiable; | |
/** | |
* The attributes that are mass assignable. | |
* | |
* @var array | |
*/ | |
protected $fillable = [ | |
'name', 'email', 'password','phone','plan','bname','acname','acnumber','actype', | |
]; | |
protected $table = 'users'; | |
/** | |
* The attributes that should be hidden for arrays. | |
* | |
* @var array | |
*/ | |
protected $hidden = [ | |
'password', 'remember_token', | |
]; | |
public function message() | |
{ | |
return $this->hasOne('App\Message','user_id'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@unless(is_null(Auth::user()->message)) | |
{{ Auth::user()->message->name }} | |
@foreach(Auth::user()->message as $message) | |
{{ $message->name }} | |
@endforeach | |
@else | |
<p>No messages</p> | |
@endunless |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment