skip to Main Content

Laravel 8.x realationship – Use HasMany in HasOne

I'm trying to use a HasMany relation in a HasOne. I have following Models: class Auction extends Model { //... public function bids(): HasMany { return $this->hasMany(Bid::class, 'auction_id'); } public function approvedBids(): HasMany { return $this->bids()->approved(); } public function topBids():…

VIEW QUESTION

update content of stored column in laravel controller

I have a table with 3 columns: firstname lastname fullname in migration: Schema::create('owners', function (Blueprint $table) { $table->id(); $table->string('firstname',20); $table->string('lastname', 20); $table->string('fullname')->storedAs('CONCAT(firstname,lastname)'); $table->timestamps(); }); the problem is that i want to change the concatenation order in the controller i tried…

VIEW QUESTION

Why am I unable to NOT use timestamps in Laravel?

I have these: posts table public function up() { Schema::create('posts', function (Blueprint $table) { $table->id(); $table->string('title', 64); $table->string('teaser', 128)->nullable(); $table->text('content', 50000); $table->timestamps(); }); } posts model use HasFactory; protected $fillable = ['title', 'teaser', 'content']; public function tags() { return $this->belongsToMany(Tag::class,…

VIEW QUESTION

Laravel "Class "App\Models\review" not found" in production

In my Laravel app there are 3 Models: Movie, User, Review Review: <?php namespace AppModels; use IlluminateDatabaseEloquentFactoriesHasFactory; use IlluminateDatabaseEloquentModel; class Review extends Model { use HasFactory; protected $hidden = ['user_id','movie_id','created_at','updated_at']; public function movie(){ return $this->belongsTo(Movie::class); } public function user(){ return…

VIEW QUESTION
Back To Top
Search