Get Tabel Name From the model in laravel [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
Im tring to get table name from the model using getTable() method but i can show the table name
$model->getTable()

If you have an instance of the model, you may call the getTable() method as described in the API reference.
<?php
$table = $model->getTable(); // string
If you do not have an instance of the model, using the app() helper is the simplest solution.
<?php
$table = app(\App\Models\User::class)->getTable();

Related

What is the Query to sort the shop on base of latest order? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
The store has a one-to-many relationship with order and I want to sort the shop with respect to the latest order so what will be the query to sort all store w.r.t latest order. Thanks-Hashir Hamza
You can use the method latest() or you can use orderByDesc('created_at')
Sample:
$orders = Order::orderByDesc('created_at')->get();
OR
$orders = Order::latest()->get();

Muitiple Data (get) VALUES [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
need to put one more element to show in controller laravel, today 'status_viagem','=','VIAGEM' works finne but need´s 'VIAGEM' and 'DESCARGA'.
My controller:
public function listaPainel(Request $request)
{
$lista = Cco::where('status_viagem','=','VIAGEM')->get();
$data['lista'] = $lista;
return view('rast.lista_painel', $data);
}
Your question is not clear. I am guessing you want to compare with more data in where condition. In this case, you may need like this:
$lista = Cco::whereIn('status_viagem', ['VIAGEM', 'DESCARGA'])->get();
You need to be more clear about your problem.

PHP - Autocomplete for magic method that receives the returning class as argument [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Having:
$ApiTokenService = Loader::get("App\\Services\\ApiTokenService");
How do I document get() method to let it know that first param would be the returning output type?
So whenever i start typing $ApiTokenService->cr.. i get create method suggest that ApiTokenService has.
I'm using PhpStorm as IDE.
I've tried things like
/**
* #param string $classPath
* #return {$classPath}
*/
But nothing has worked so far.
And PHPStorm metadata file:
<?php
namespace PHPSTORM_META {
override(\Loader::get(), type(0));
}

Laravel calling other controller variable [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have 2 files in laravel. One is dashboard.blade.php and withdraw.blade.php. Both have a controller for dashboard i.e. dashboardcontroller and similarly for withdraw withdrawcontroller. I have a variable in dashboardcontroller name $approveMediatotal. How do I reference it in withdraw.blade.php?
you can do this by using Session
Session::put('key', 'value');
Session::get('key');
In dashboardcontroller :
Session::put('approveMediatotal', $approveMediatotal);
and then , in withdrawcontroller :
$res = Session::get('approveMediatotal');
return view('withdraw')->withApproveMediaTotal($res);
you can find more information here

retrieving a row using laravel eloquent ORM [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to get back single row where a user just added a new car. I am trying to join all tables using the eloquent ORM. here is a erd of my database I am new to laravel, and I would want to know how I would be able to achieve this. Thanks in advance.
What have you tried already?
Assuming you want to get latest added Car model, you could do
$latestCar = Car::orderBy('id', 'DESC')->first();
If you have nothing yet, you could watch Laracasts about how to build a database and set up Models.

Categories