Go Premium for a chance to win a PS4. Enter to Win

x

Eloquent ORM

Eloquent ORM (object-relational mapping) is a component of the Laravel framework, used to establish and maintain the relationships between database objects. Following the active record pattern, Eloquent ORM presents database tables as classes and maps application objects to database tables.

Share tech news, updates, or what's on your mind.

Sign up to Post

I'm creating pagination manually for results using Eloquent ORM. The pagination works fine except it's defaulting to display only back and next buttons (simplePaginate()) rather than back, next and page number links.

Here's how I'm generating the pagination;

$data = new \Illuminate\Pagination\Paginator($allRecipes, $perPage, $page, ["path" => "recipes"]);

Open in new window


Is there a way I can ask for the pagination to not be the equivalent of calling 'simplePaginate()'?
0
[Webinar] Cloud and Mobile-First Strategy
LVL 11
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

I am having a really hard time getting past this metadata resource error. I gave googled it and tried lost of solution., Ideas?

<add name="MyContext" connectionString="metadata=res://*/Models.MyStuff.csdl|res://*/Models.MyStuff.ssdl|res://*/Models.MyStuff.msl;provider=System.Data.SqlClient;provider connection string='data source=usb-apqa3.myDomain.com;initial catalog=MyTable;persist security info=True;User ID=Ccap; Password=l7a1vYtKPoCKTOOK8sxdq3IipOqg3Ox0v9jF1hm9wNLenvtSi8;MultipleActiveResultSets=True;App=LCA';" providerName="System.Data.EntityClient" />
0
Hi,
I have a list of vehicles in a mysql db and I'm building a query within my controller using laravel framework.
My problem is I have 2 columns (vehicle_price and discount_price)
I'm trying to return my result order by lowest price on up.

Because some values exist in the discount_price column I can't figure out how to return a list with the lowest prices ascending taking both columns into account.

You'd think perhaps I could test if there is a value in the discount_price, use that  but no idea what to do.

fyi: when the discount_price column is 'empty' its a 0 (zero)

	public function showUsed()
	{
	
	$vehicles = DB::table('used_vehicles')
			->join('dealerships', 'used_vehicles.dealer_id', '=', 'dealerships.id')
			->join('makes', 'used_vehicles.make_id', '=', 'makes.id')
			->join('models', 'used_vehicles.model_id', '=', 'models.id')
			->join('used_vehicles_categories', 'used_vehicles.category_id', '=', 'used_vehicles_categories.id')
			->select('used_vehicles.*','dealerships.name','dealerships.address_street','dealerships.address_city','dealerships.address_province','dealerships.address_postal_code','dealerships.phone','dealerships.toll_free_phone','makes.name as make_name','models.model_name as model_name','used_vehicles_categories.category_title as category_name')
			->orderBy('used_vehicles.vehicle_price', 'asc')
			->paginate(30);
		
		return view('/pages/used/index', ['vehicles' => $vehicles]);

	}

Open in new window

0

Eloquent ORM

Eloquent ORM (object-relational mapping) is a component of the Laravel framework, used to establish and maintain the relationships between database objects. Following the active record pattern, Eloquent ORM presents database tables as classes and maps application objects to database tables.

Top Experts In
Eloquent ORM
<
Monthly
>

No Top Experts for this time period. Answer questions to earn the title!