Created
April 21, 2019 23:41
-
-
Save jpalala/88e08d253a3b22483f648a837aa56442 to your computer and use it in GitHub Desktop.
idea for a fat model in laravel for a spa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Fat extends Model | |
{ | |
public function all() { | |
$sponsors = DB::select(DB::raw("SELECT * FROM sponsors LIMIT 10")); | |
$events = DB::select(DB::raw("SELECT * FROM events ORDER BY event_date DESC LIMIT 1")); | |
$articles = DB::select(DB::raw("SELECT * FROM articles ORDER BY published_at DESC LIMIT 3")); | |
return [ | |
'sponsors' => $sponsors->toJson(), | |
'events' => $events->toJson(), | |
'articles' => $articles->toJson() | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment