Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2.  
  3. namespace laravel;
  4.  
  5. use IlluminateDatabaseEloquentModel;
  6.  
  7. class Producto extends Model
  8. {
  9.  
  10.  
  11. public function user()
  12. {
  13. return $this->belongsTo('User::class');
  14. }
  15. protected $table='productos';
  16. protected $primaryKey='idProducto';
  17. public $timestamps=false;
  18.  
  19. protected $fillable =[
  20. 'idSubcategoria',
  21. 'id',
  22. 'nombre',
  23. 'descripcion',
  24. 'imagen',
  25. 'stock',
  26. 'costo_unitario',
  27. 'Unidad_de_medida',
  28.  
  29. ];
  30.  
  31.  
  32.  
  33. }
  34.  
  35.  
  36.  
  37. <?php
  38.  
  39. namespace laravel;
  40.  
  41. use IlluminateNotificationsNotifiable;
  42. use IlluminateFoundationAuthUser as Authenticatable;
  43.  
  44. class User extends Authenticatable
  45. {
  46.  
  47.  
  48.  
  49. public function productos()
  50. {
  51. return $this->hasMany('Producto::class');
  52. }
  53. use Notifiable;
  54.  
  55. /**
  56. * The attributes that are mass assignable.
  57. *
  58. * @var array
  59. */
  60. protected $fillable = [
  61. 'name', 'email', 'password',
  62. ];
  63.  
  64. /**
  65. * The attributes that should be hidden for arrays.
  66. *
  67. * @var array
  68. */
  69. protected $hidden = [
  70. 'password', 'remember_token',
  71. ];
  72. }
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. public function user(Request $request,$name)
  80. {
  81. $productos = Producto::all();
  82. $user =User::select()
  83. ->where('name','=',$name)
  84. ->first();
  85. return view("store.user",compact('user','productos'));
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement