Skip to content

Instantly share code, notes, and snippets.

@nikhilj1
nikhilj1 / Model.php
Last active June 26, 2017 13:37
Polymorphic relations
<?php
namespace App;
class User extends Model
{
public function role()
{
return $this->morphTo();
}
}
@nikhilj1
nikhilj1 / gist:cbdf0decf1df2037d3b5230344396a47
Created June 28, 2017 10:22 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
/**
* App\User
*
* @property int $id
@nikhilj1
nikhilj1 / Student.php
Last active December 21, 2017 18:30
Student isValid
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Student extends Model {
public function scopeIsValid($query, $name,$dob){
return (!empty($query->where('name', $name)->where('dob',$dob)->get())?true:false);
}
}
@nikhilj1
nikhilj1 / Post.php
Created July 22, 2020 09:48
Error While Testing with Faker Code.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
/**
* App\Post
*/
class Post extends Model