Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace laravel;
- use IlluminateDatabaseEloquentModel;
- class Producto extends Model
- {
- public function user()
- {
- return $this->belongsTo('User::class');
- }
- protected $table='productos';
- protected $primaryKey='idProducto';
- public $timestamps=false;
- protected $fillable =[
- 'idSubcategoria',
- 'id',
- 'nombre',
- 'descripcion',
- 'imagen',
- 'stock',
- 'costo_unitario',
- 'Unidad_de_medida',
- ];
- }
- <?php
- namespace laravel;
- use IlluminateNotificationsNotifiable;
- use IlluminateFoundationAuthUser as Authenticatable;
- class User extends Authenticatable
- {
- public function productos()
- {
- return $this->hasMany('Producto::class');
- }
- use Notifiable;
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $fillable = [
- 'name', 'email', 'password',
- ];
- /**
- * The attributes that should be hidden for arrays.
- *
- * @var array
- */
- protected $hidden = [
- 'password', 'remember_token',
- ];
- }
- public function user(Request $request,$name)
- {
- $productos = Producto::all();
- $user =User::select()
- ->where('name','=',$name)
- ->first();
- return view("store.user",compact('user','productos'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement