Created
February 20, 2016 22:59
-
-
Save codyphobe/083c609bdd440cf9b8ca to your computer and use it in GitHub Desktop.
Laravel 5.1 Read only Model
This file contains 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 | |
//Similar to Rails Active Directory Read only models in ruby gems | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class ReadOnly extends Model | |
{ | |
public $table = 'tablename'; | |
protected $connection = 'db_test'; | |
// protected static $carbonFields = ['created_at', 'updated_at', 'deleted_at']; | |
protected static $carbonFields = []; | |
public function save(array $options = []){ | |
return false; | |
} | |
public function update(array $attributes =[]){ | |
return false; | |
} | |
static function firstOrCreate(array $arr){ | |
return false; | |
} | |
static function firstOrNew(array $arr){ | |
return false; | |
} | |
public function delete(){ | |
return false; | |
} | |
static function destroy($ids){ | |
return false; | |
} | |
public function restore(){ | |
return false; | |
} | |
public function forceDelete(){ | |
return false; | |
} | |
/* We need to disable date mutators, because they brake toArray function on this model */ | |
public function getDates(){ | |
return array(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment