المشاركات

Can you show database records on a View with no Controller in Laravel?

I am new to Laravel and I tried to create an application for an admin. I did other pages first where I ran queries to pull data from the database and display in tables. I made use of an admin middleware for security and if the user in an admin, they get taken to my Dashboard screen(which I left blank till now). Now I want to add items to that Dashboard page and some database records would need to be on it but I see that I have no controller for my Dashboard page. Is there any way to work around this so that I can run these queries? from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Uh77dP via IFTTT

Pass my valuess from php to html in laravel [closed]

This is the output of SQL Query. I am using Laravel. I want to pass these values to chart i dont know how. I am new to this can any one help me. [{"num":"2021-06-24","createdcount":1},{"num":"2021-07-02","createdcount":3},{"num":"2021-07-05","createdcount":1},{"num":"2021-07-06","createdcount":1},{"num":"2021-07-07","createdcount":2},{"num":"2021-07-08","createdcount":2},{"num":"2021-07-09","createdcount":2},{"num":"2021-07-10","createdcount":3},{"num":"2021-07-11","createdcount":2},{"num":"2021-07-12","createdcount":1},{"num":"2021-07-13","createdcount":2},{"num":"2021-07-14","createdcount":2},{"num":"2021-07-15...

Parse Json content in model in Laravel

I have a payment and Payment history models Payment History: class PaymentHistory extends Model { public function subscription() { return $this->hasOne('App\Models\Payment', 'id','payment_id'); } } Payment : class Payment extends Model { public function PaymentHistory(){ return $this->belongsTo('App\Models\PaymentHistory ','id','payment_id'); } } I have a json column named as response in Payment History table that i want to return it after decoding json data in model function with each and every row My query in controller is as follows $data = User::with('Payment.PaymentHistory')->get(); i was trying to do something like this in payment history model: public function json_response() { return json_decode($json, TRUE); } Any help is highly appreciated from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3xPnwEI via IFTTT

i found some syntax error using where function in query (laravel)

i have two condition which i want to implement in a query but when i used i found some systax error but i did not how to solved it. error in the below: syntax error, unexpected '}' and my controller code is : public function paymentHubList(Request $request, $id){ $Abc = new Abc(); $Abc = $Abc->where('status_id','1')->where('payment','1') ->where(function($query){ $query->where(function($query){ $query->where('delivery',$id)->where('paid','!=','0'); }) ->orWhere(function($query){ $query->where('branch',$id)->where('paid', '0'); }) }) ->orderBy('id','desc')->paginate(100); dd($...

How to count downlines in Laravel?

$i = $_SESSION['ruserid'];// the list will show the downline for a member with id = 10 prin($i);// calling function prin function prin($i) //definition { $id = $i; // $q=mysql_query("select id from f2_users where up_id='$id'"); $q = User::where('sponser_id', $i)->get(); $count = count($q);// gives new value each time foreach ($q as $r) { $i = $r[0]; echo $i; echo "<br>"; prin($i); // recursion } } How to convert above php code in laravel controller to get downlines? Blockquote from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3hKS5Wi via IFTTT

Integrity constraint violation: 1048 Column 'cd_id' cannot be null in laravel

صورة
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'cd_id' cannot be null (SQL: insert into commvendordata ( new_date , cd_id , cn_id , unit_id , vender1 , vender2 , vender3 , vender4 ) values (07/17/2021, ?, ?, ?, ?, ?, ?, ?)) how remove this error using laravel form or blade screenshot <form action="" method="POST" class="shadow-lg p-4 w-f"> @csrf <div class="modal-date"> <label>Select Date:&emsp;&emsp;</label> <input type="text" name="new_date" placeholder="Select Price Date" class="getdate"/> <button type="button" name="loadform" class="btn btn-warning load-form">Load Form</button> </div> <div class="data" style="display:none;"...

Laravel join 3 tables using Query Builder

I have a function that expects a query builder as input parameter. On the query I want all the records returned from this query: $query = $model->newQuery() ->leftJoin('materials', 'products.material_id', '=', 'materials.id') ->leftJoin('vehicles', 'products.vehicle_id', '=', 'vehicles.id') ->leftJoin('parts', 'products.part_id', '=', 'parts.id') ->select( 'products.id as id', 'products.name as product_name', 'parts.part_name as part_name', 'materials.public_name as material', 'vehicles.name as vehicle' ); Using leftJoin the function runs but returns nothing and if I replace leftJoin for join (what I think it's the right solution for this case) vsc says it's not a Query Builder and executi...