Select Query in Laravel 5
The query builder can also select existing records using the select method, you can specify a custom select clause for the query. $getdetail = DB::table(‘search_logs’) ->select(‘shape’, ‘color’, ‘cut’) ->get();
The query builder can also select existing records using the select method, you can specify a custom select clause for the query. $getdetail = DB::table(‘search_logs’) ->select(‘shape’, ‘color’, ‘cut’) ->get();
You can build your query step-by-step and then call get() method. But sometimes it gets a little tricky for more complicated queries – for example, if you have multiple whereIn OR whereIn conditions and you want to put brackets, do…
Just today, I was looking at using a ternary operator in Laravel’s Blade templating system. However, instead of writing a ternary statement, Blade provides you with the following convenient short-cut: {{ $string or ‘something’ }} In this example, if the…
Most of the time my clients need to download data from their database tables. Today, I decided to make a very small controller that is portable and efficient for exporting full MySQL tables to Excel using PHPExcel in laravel 8.…
The query builder may also be used to write join statements. To perform a basic “inner join”, you may use the join method on a query builder instance. The first argument passed to the join method is the name of…
The query builder may also be used to delete records from the table via the delete method. You may constrain delete statements by adding where clauses before calling the delete method. DB::table(‘cart_products’)->where(‘id’, ‘=’, $cart_id)->delete();
The query builder can also update existing records using the update method. The update method, like the insert method, accepts an array of column and value pairs containing the columns to be updated. $query_update = DB::table(‘cart_products’) ->where(‘user_id’, $id) ->update([‘status’ =>…
The query builder also provides an insert method for inserting records into the database table. The insert method accepts an array of column names and values. Insert query work with ajax, form to pass the get and post method. $responce…
Ajax makes your application more flexible, you don’t need to reload or refresh the whole body for small changes, you can made changes in any part without loading page. How to Call ajax in Laravel 5 File Upload in Laravel…
ware <?php namespace App\Http\Middleware; use Auth; use Closure; class UserMiddleware { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if(Auth::check()) { if(Auth::user()->is_admin !=…