本文整理汇总了PHP中app\Language::findOrNew方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::findOrNew方法的具体用法?PHP Language::findOrNew怎么用?PHP Language::findOrNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Language
的用法示例。
在下文中一共展示了Language::findOrNew方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Execute the job.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle()
{
// Language.
$language = Language::findOrNew(1);
if (!$language->id) {
$language->id = 1;
$language->name = 'english';
$language->prefix = 'en';
$language->save();
}
// Country.
$country = Country::findOrNew(1);
if (!$country->id) {
$country->id = 1;
$country->name = 'spain';
$country->prefix = 'spa';
$country->save();
}
// User.
$user = User::findOrNew(1);
if (!$user->id) {
$user->id = 1;
$user->name = 'Test';
$user->surname = 'Test';
$user->email = 'test@test.com';
$user->direction = 'this should be called address lol';
$user->birthday = '2000-01-01';
$user->language_id = $language->id;
$user->country_id = $country->id;
$user->save();
}
$created = $user->tasks()->create($this->requestParams);
return response()->json($created);
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$nl = Language::findOrNew(1);
$nl->lang = "nl";
$nl->save();
$gb = Language::findOrNew(2);
$gb->lang = "gb";
$gb->save();
}