@kazim.karagul hocam cevap için teşekkürler.
user model
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zizaco\Entrust\Traits\EntrustUserTrait;
class User extends Authenticatable {
use EntrustUserTrait;
protected $fillable = [
'name',
'email',
'password',
'remember_token',
'created_at',
'updated_at',
'password2',
'hitap',
'durumu',
'cep',
'istelefon',
'il',
'ilce',
'adres',
'kaynak',
'satistemsilcisi',
'faturabilgisi',
'not',
'meslek',
'kaynakdiger',
'tc',
'vergidairesi',
'vergino',
'faturaadi',
'ekleyenid',
'faturail',
'faturailce',
'faturaadres2',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function bolumler() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->belongsTo('App\Bolum', 'bolumid');
}
public function majorlar() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->belongsTo('App\Major', 'majorid');
}
public function durumlar() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->belongsTo('App\Durum', 'durumu');
}
public function satis() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->belongsTo('App\User', 'satistemsilcisi');
}
public function akademik() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->belongsTo('App\User', 'akademikdanisman');
}
public function paketler() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->belongsTo('App\Paket', 'okulid');
}
public function programlar() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->belongsTo('App\Program', 'programid');
}
public function taksit() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->hasMany('App\Taksit', 'userid');
}
public function randevular() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->hasMany('App\Randevu', 'musteriid');
}
public function randevular2() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->hasMany('App\Randevu', 'danisman');
}
public function notlar() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->hasMany('App\Not', 'userid');
}
}
not model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Not extends Model
{
public $fillable = ['id','userid','not','mail'];
public function notu() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->belongsTo('App\User', 'userid');
}
}
controller
$data = User::with('notlar')->whereHas('roles', function($q) {
$q->where('id', '3');
})->orderBy('id', 'DESC')->get();
blade
@extends('layouts.app')
@section('content')
<section class="content">
<form action="{{ url('exportPDF') }}" method="get">
<!-- /.box -->
<div class="box">
<div class="box-header">
<h3 class="box-title">Müşteri İşlemleri</h3>
@if ($message = Session::get('success'))
<div class="alert alert-success">
<p>{{ $message }}</p>
</div>
@endif
<table>
<td></td>
@role(['Lord'])
<td><div align="right"><div class="btn-group">
<button type="button" class="btn btn-danger">Site Evrakları</button>
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><button type="submit" class="btn btn-warning btn-block" name="excel" value="excel">Adalettv Satış Sözleşmesi</button></li>
<li class="divider"></li>
<li><button type="submit" class="btn btn-warning btn-block" name="pdf" value="pdf">ePsikologTV Satış Sözleşmesi</button></li>
</ul>
</div> </td>
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
<td><div align="right"><div class="btn-group">
<button type="button" class="btn btn-warning">Raporlama</button>
<button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Rapor 1</a></li>
<li><a href="#">Rapor 2</a></li>
<li><a href="#">Rapor 3(xls)</a></li>
<li class="divider"></li>
<li><button type="submit" class="btn btn-danger btn-block" name="excel" value="excel">ExcelRaporlama</button></li>
<li class="divider"></li>
</ul>
</div> </td>
@endrole
<td > <a class="btn btn-success" href="{{ route('ogrenci.create') }}">Yeni Müşteri Ekle</a></div></td>
</tr>
</table>
</div>
<!-- /.box-header -->
<div class="box-body">
<!-- Check all button -->
<div class="table-responsive mailbox-messages">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr >
<th></th>
<th><i class="fa fa-fw fa-sort-amount-asc"></i></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th><th></th>
</tr>
</thead>
<thead>
<tr>
<th><button type="button" class="btn btn-default btn-sm checkbox-toggle"><i class="fa fa-square-o"></i>
</button></th>
<th>No</th>
<th>Ad Soyad</th>
<th>Eposta</th>
<th>Durumu</th>
<th>Telefon</th>
<th>S. D</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$i=0;
?>
@foreach ($data as $key => $user)
<tr>
<td> <input type="checkbox" class="minimal" name="rapor[]" value="{{ $user->id }}"></td>
<td>{{ ++$i }}</td>
<td>{{ ucwords(strtolower($user->name)) }}</td>
<td>{{ $user->email }}</td>
<td>
<label class="label label-success">
@if(!empty($user->durumlar->durumname))
{{ $user->durumlar->durumname }}
@endif
</label>
</td>
<td>
Cep: {{ $user->cep }}<br>
İş: {{ $user->istelefon }}
</td>
<td>
@if(!empty($user->satis->name))
{{ $user->satis->name }}
@endif
</td>
<td>
@foreach ($data as $user)
{{ $user->notlar }}
@endforeach
</td>
<td>
<a class="btn btn-success" href="https://www.mezbilisim.com/magaza" target="_blank">Ödeme</a>
@role(['Lord'])
<a class="btn btn-danger" href="{{ route('ogrenci.cariStore',$user->id) }}">Cari</a>
@endrole
<a class="btn btn-info" href="{{ route('ogrenci.show',$user->id) }}">Göster</a>
<a class="btn btn-primary" href="{{ route('ogrenci.edit',$user->id) }}">Düzenle</a>
@role(['Lord','Yonetici'])
<a class="btn btn-danger" href="{{ route('ogrenci.destroy',$user->id) }}">Sil</a>
@endrole
</td>
</tr>
@endforeach
</tbody>
<tfoot>
<th></th>
<th>No</th>
<th>Ad Soyad</th>
<th>Eposta</th>
<th>Durumu</th>
<th>Telefon</th>
<th>S. D</th>
<th>Action</th>
</tfoot>
</table>
<!-- /.table -->
</div>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</form>
</section>
@endsection