samedi 24 juillet 2021

Class 'Admin::class' not found (View:... in laravel 8

Whene i would right a name for a person who i have a secondly key he give me this probleme ,so i right this type of code in larvel 5 so i don't know this is a problem in laravel 8 when i would changed in more details or another problem for more explication this is my code :

<thead>
    <tr>
      <th scope="col">name</th>
      <th scope="col">Adress</th>
     <th scope="col">number</th>
       <th scope="col">admin name</th>
    </tr>
  </thead>
  @if($administrations)
  @foreach($administrations as $administration)
  <tbody>

    <tr>
      <th scope="row"></th>
      <td>{!!$administration->adress!!}</td>
      <td></td> 
      <td></td> 
      
    </tr>
  </tbody>
  @endforeach
  @endif

And this is a code for my controller :

 public function storefac(Request $request){
$this->validate($request,[
"name"=> 'required',
"number"=>'required',
"adress"=>'required',
]);
$id=Auth::user()->id;
$emps=new Administrations;
$emps->name=$request->input('name');
$emps->adress=$request->input('adress');
(integer)$emps->number=$request->input('number');
$emps->id_superAdmin=$id;
$emps->save();
return redirect()->back()->with('success','data saved');

And code for my two models ( admin and administration):

class Administrations extends Model
{
    protected $fillable = [
            'name',
            'address',
            'number',
            'id_Admin'
    ];

   public function admin()
    {
        return $this->belongsTo('Admin::class');
    }


class Admin extends Model
{
    protected $fillable = [
        'name',
        'grade',
    'adress',
'number',
        'id_user'
    ];

 public function users()
    {
        return $this->belongsTo('User::class');
    }
    public function administrations ()
    {
        return $this->hasOne('Administrations::class');
    }



Aucun commentaire:

Enregistrer un commentaire