$content = Storage::disk('s3')->get($path);
$header = [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="'.$file->name.'"'
];
return Response::make($content, 200, $header);
$follower->follower->username_slug
$userinfo->following()->count()
$userinfo->following()->take(12)->get()
href="/profile/{{ $following->followed->username_slug }}"
route('name', $slug)
dd($usersinfo)
public function users() {
return $this->belongsToMany('App\User', 'user_department', 'departament_id', 'user_id');
}
$departaments = Department::with('users')
->get();
@foreach ($departaments as $departament)
@foreach ($departament->users as $user)
{{$user->name}}
@endforeach
@endforeach
Article::where('alias',$alias)
->latest()
->take($take)
->paginate($paginate);
Category::with(['articles' => function($query) use ($alias,$take) {
$query->where('alias',$alias)->запрос;
}])->запрос->paginate($paginate);
$product = Product::find($product_id);
// hasMany
$product->category->delete();
// manyToMany
$product->categories()
->find($category_id)
->delete();
// Просто удалить категорию
Category::find($id)->delete();
// Удалить категорию У товара (открепить)
$product->categories()
->detach($category_id);
Product::with(['relatedSpecsGroup' => function($query) {
$query->orderBy('position', 'desc');
}])
->orderBy('relatedValue', 'desc')
->get();
// удаляем поле
Schema::table('auto', function (Blueprint $table) {
$table->dropColumn('remove_field');
});
// добавляем поле
Schema::table('auto', function (Blueprint $table) {
$table->integer('add_field')->nullable();
});
$slug = Str::slug($name);
Route::get('{slug_category}/{slug_post}', 'PostController@show')->name('post.show');
{{route('post.show', [$category->slug,$post->slug])}}
$user = Auth::user();
if ($user->isAdmin) {
// code...
}else{
// code...
}
// не админ
if (!$user->isAdmin) {
// code...
}
'/{user}/orders'
$user=User::find($user_id);
$orders = $user->orders;
public function news()
{
return $this->belongsToMany('App\News', 'news_to_rubric', 'rubric_id', 'news_id');
}
$rubrics = Rubric::with('news')
->get();
@foreach ($rubrics as $rubric)
{{$rubric->name}}
@foreach ($rubric->news as $news)
{{ $news->name }}
@endforeach
@endforeach
$schedule->call(function(){
(new \App\Http\Controllers\ParserController)->parserSite1();
})->everyMinute();