Answers for "two conditions inside if - laravel 8"

PHP
0

write if and else in one line laravel

//in blade:
{{ ($data->position == 1) ? 'active' : 'disable'}}

//in Controller
$result = ($data->status == 1) ? 'active' : 'disable'
Posted by: Guest on November-08-2020
1

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

Code answers related to "two conditions inside if - laravel 8"

Browse Popular Code Answers by Language