These works but probably you didn't use the right namespace
, just use the use
statement at the top of your class
name like this:
<?php namespace SomeNamespace;
use AppQuotation; // Says "Quotation.php" is in "App" folder (By default in L-5.0)
class someClass {
//...
}
Then you may use in your method
something like this:
// You may add: use DB; at the top to use DB instead of DB
$random_quote = Quotation::orderBy(DB::raw('RAND()'))->first();
Or this:
$random_quote = Quotation::orderByRaw("RAND()")->first();
Update (Since Laravel - 5.2):
$random_quote = Quotation::inRandomOrder()->first();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…