Posts

Showing posts with the label Laravel

Join vs Model vs Relationship in Laravel

Understanding SQL joins, Eloquent relationships, and model accessors. 1) Join (Database level) A join is a database operation used to combine rows from multiple tables. It happens at the SQL level and is focused on performance and filtering. Example: SELECT users.name, posts.title FROM users JOIN posts ON posts.user_id = users.id; Runs in the database Returns raw rows Very fast 2) Relationship (Eloquent ORM level) A relationship defines how models are connected. It represents business meaning, not just raw data. class User extends Model { public function posts() { return $this->hasMany(Post::class); } } Usage: $user->posts; Returns model objects Supports lazy & eager loading Encodes domain logic 3) Model Accessor (Presentation level) An accessor is a computed attribute on a model. It does not fetch data from the dat...

File cannot open in append mode in Laravel in Rocky Linux

 After changing permission: sudo setenforce 0   Credit: https://stackoverflow.com/questions/63203144/file-could-not-be-opened-in-append-mode-failed-to-open-stream-permission-denie