Skip to content

Instantly share code, notes, and snippets.

@jpalala
Created April 21, 2019 23:41
Show Gist options
  • Save jpalala/88e08d253a3b22483f648a837aa56442 to your computer and use it in GitHub Desktop.
Save jpalala/88e08d253a3b22483f648a837aa56442 to your computer and use it in GitHub Desktop.
idea for a fat model in laravel for a spa
<?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