Skip to content

Instantly share code, notes, and snippets.

@aaoliveira
Created March 7, 2016 00:20
Show Gist options
  • Save aaoliveira/be9351d7d9a0a071a39f to your computer and use it in GitHub Desktop.
Save aaoliveira/be9351d7d9a0a071a39f to your computer and use it in GitHub Desktop.
Classe seguimentos
<?php
namespace app\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Class Segment.
*/
class Segment extends Model
{
public $timestamps = false;
protected $fillable = [
'description',
'company_id',
];
protected $guarded = [];
protected function initEnsinoInfantil($companyId, $empresa)
{
$data = [
[
'company_id' => $companyId,
'description' => 'Educação Infantil',
],
];
// 1 - maneira
$infantilSave = $this->save($data); // falha
// 2 - maneira
$infantilSave = parente::create($data); // falha
// 3 - maneira
$infantilSave = Model::create($data); // falha
if (!$infantilSave) {
throw new Exception("Não foi possivel realizar o cadastro dos seguimentos de series ensino infantil da escola {$empresa}. Por favor, tente novamente ou entre em contato com o Administrador.");
}
return $infantilSave;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment