$query
->select('name')
->where('language_id',$lang_id);
Привет, подскажите где писать код который должен выполняться на всех страницах сайта, но только для авторизованного?
view()->composer(['index.layouts.header', 'index.layouts.footer'], function ($view) {
$view->with(compact('data'));
});
Пытался писать в AppServiceProvider но судя по всему он грузится раньше чем проверяется авторизация пользователя.
protected function validator(array $data)
{
return Validator::make($data, [
'verification_code' => 'exists:verification_code_tables,verification_code_column'
]);
}
public function rules()
{
$model = Model::firsy();
return [
'phone' => new Rule($model),
'phone1' => new Rule1($model),
'phone2' => new Rule2($model),
];
}
$ids = Tag::where("user_id", Auth::user()->id)->pluck('id')
Post::select("name")->whereIn($ids)->get()
select
sum(case when type = "all" then 1 else 0 end) as "all",
from (values ('2019-01-12', '2019-07-12')) AS dates (dateStart, dateEnd)
inner join users on users.created_at > dates.dateStart::date and users.created_at < dates.dateEnd::date
group by dates.dateStart::date
select dates.dateStart::date, type, count(*)
group by dates.dateStart::date
public function save(Request $request) {
$model = Model::query()->updateOrCreate($request->all());
$this->createRelation($request->all(), $model);
}
public function createRelation($data, $model) {
foreach ($data as $key => $value) {
if (method_exists($model, $key)) {
$relation = $model->$key()->updateOrCreate($value);
$this->createRelation($value, $relation);
}
}
}
Model::orderBy('field','desc')->skip(50)->take(50)->reverse();
$sql = Model::orderBy('field','desc')->take(100)->toSql();
$reslut = Model::from(DB::raw("($sql) as tabes"))->orderBy('field')->take(50)->get()
matchMany($models, $queryResults, $relation, $related, $foreignKey, $primaryKey)
public function relatedOrders()
{
return $this->hasMany(self::class, "parent_id", "id")->fromHighPriceOrders();
}
$objProducts = Products::find($id);
if(!$objProducts){
return abort('404');
}
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'adminusers',
],
]
public function authenticate()
{
if (Auth::attempt(['email' => $email, 'password' => $password])) {
// Аутентификация успешна...
return redirect()->intended('dashboard');
}
}