Reputation: 764
I'm relatively new to Laravel, but I think I'm understanding it pretty well. </unintentional-rhyme>
I'm creating a base package for a project, and it needs to interact with a database (which has been set up and functioning - I did a lot of logic in Route closures and am refactoring it).
I had DB::table('shops')->where(...
but it gave me a Class \xxx\xxx\DB not found
or whatnot; so I changed it to
\DB::table('shops')->where(...
to fix the namespaces.
Is this the proper way to alleviate the issue within a package? I don't want to be causing some sort of issue that comes back to bite me down the road.
Thanks
Upvotes: 0
Views: 55
Reputation: 594
Shop::where('condition', 'value')->get();
check laravel doc http://laravel.com/docs/eloquent
Upvotes: 1
Reputation: 1975
You have to declare it at the top like so
<?php
use DB;
class myClass {
public function foo () {
DB::insert('insert into users (id, name) values (?, ?)', array(1, 'Dayle'));
}
}
Upvotes: 1