Answers for "where condition in blade laravel bd"

PHP
0

laravel where condition with if

$query = DB::table('user_ads')
            ->join('ads', 'users_ads.ad_id', '=', 'ads.id')
            ->orderBy($column, $method);

if ($input['search']) {
    $query->where('short_description', $input['search']);
}

if ($input['category']) {
    $query->where('category', $input['category']);
}

$query->join('users', 'users_ads.user_id', '=', 'users.id')
    ->select('ads.id', 'ads.img1', 'ads.short_description', 'ads.category', 'ads.product', 'ads.price', 'users.city')

$result= $query->get();

return $result;
Posted by: Guest on September-13-2020
0

laravel where and blade

// NOTE: all project with open and processed that you have not submitted an offer yet.

// NOTE 1 (Controller): all projects with open and processed
$projects = Project::whereIn('status_id', [2,3])->get();

// NOTE 2 (Blade):
@if (count($project->projectOffers->where('teacher_id',auth()->user()->id)) == 0)
// Your code
@endif
Posted by: Guest on April-28-2021

Browse Popular Code Answers by Language