Questions tagged [laravel-models]

91 questions
0
votes
0 answers

MODELS: Cannot update values in DB

I have this function to update the DB values, but one of the statements is not working. I created a relation to the table called ventas, however, it is not updating it´s value to NULL. This is my code: public function cambiarEstatusFactura( Request…
Rodri6uez
  • 399
  • 1
  • 5
  • 14
0
votes
2 answers

Error class "app\Models\BlogPost" not found

I'm using a MySQL (XAMPP) database, which I have linked in the .env file of my Laravel folder. I'm trying to use the database to show "blog posts" on the posts.index page, and it isn't showing any errors in visual studio code, but when I go to the…
nobah
  • 1
  • 5
0
votes
1 answer

How to log notifications laravel 8 after fired

guys, I create a panel with laravel 8 and create some emails jobs that must send emails to specific users on specific dates it works fine. I created the database with 2 columns user_id (id of the user that email sent to him/er) and type (type of…
0
votes
1 answer

Invalid argument supplied for foreach() view returning null

When I created a variable in the Model named "statuses" and called it back in controller I got the array data. However when calling the second variable it's returning null and giving me error in the blade. In Model /** * Statuses. * * @var array …
David Buik
  • 522
  • 1
  • 8
  • 31
0
votes
2 answers

changing the default Laravel table names from plurals to own custom names

I’m trying to change a Laravel's default table name from its model name and plural to the other custom name. From reading around I thought I had to just update that in the app/Model/User.php for example then am done. But unfortunately its not…
0
votes
1 answer

laravel withCount() Cardinality violation error when relationship is hasMany

This is my models: //project model class Project extends Model { ..... public function items(){ return $this->hasMany(ProjectItem::class,'project_id'); } } //project items model class ProjectItem extends Model{ ... public…
dev-jim
  • 2,404
  • 6
  • 35
  • 61
0
votes
1 answer

How to present two tables which have a relation between them like the case of the "sales" table and "sales_content" using the laravel model

I have two tables in my database, one for "sales" informations and the other for "sale content" (items). What is the best method to present this using the laravel models? For example, is it better to create a model for each table or can we only use…
Omar
  • 300
  • 5
  • 14
0
votes
0 answers

Laravel - Why is model not saving?

I'm using the laravelista comments package to make comments for my site. When trying to create a comment, the POST method goes through (with the commentable model and its id properly referenced), but the comment is not being saved. I know the…
0
votes
0 answers

Laravel 8: Relationships Between User and Posts. Outputting Data and Storing into Database

This is a continuation of my last question. I like to create a relationship between a user (with an account type that’s equal to a “profile”) and my job posts. What I did was create a relationship like this in my models (not sure if correct…
Ginz77
  • 63
  • 3
  • 10
0
votes
0 answers

Using models in laravel didn't work but worked when using routes

I'm just starting using laravel and there's a problem when i'm using models. I already make a dummy data inside model in profilesModel.php private static $pData = [ "pNamaLengkap" => "Anro Anderson", "pJobDescription" => "Full Stack…
0
votes
1 answer

Is there a way to get all the relations and fields of particular model in laravel?

I am trying to create a script that could help me generate a GraphQL schema with all fields and relations exist in the models. if I could get that, php-lighthouse would help me for the rest of the work.
0
votes
1 answer

How to link observer to another file in laravel?

I write one observer called userObserver.php and I write one task file called DeleteTask.php which contains DB queries , now I want to make a link with the observer to the DeletTask.php file
Code cracker
  • 316
  • 1
  • 5
  • 20
0
votes
3 answers

Eloquent model update returns true but db change not reflecting

I have a model called CustomerInfo and i am trying to update it. update returns true but the changes are not reflecting on my db. $customerInfo = CustomerInfo::where('machine_name',$username)->firstOrFail(); $result =…
0
votes
0 answers

How to count total comments with replies of a topic in Laravel

I have a topic that contain comments and each comment can contain replies. However, I want to optimize the way I count the total comments of each topics (comment + reply). In my Topic model, I can optimally get the comment count using this…
0
votes
1 answer

How to pass condition in laravel 5 relation model

I am trying to get the data from group model but i am relate the student table new_group_id to group table id if it not null else connect the group_id to group table id. public function grade(Builder $query) { return $query …