Posts

Since 2024
Tablar Kit: UI Components for Tablar Admin Dashboards
Tablar Kit: UI Components for Tablar Admin Dashboards

The Tablar Kit package for Laravel adds a UI kit for your Tablar admin dashboard. This UI kit adds many easy-to-use components, making your dashboard more visually appealing and user-friendly. It's all about simplicity and enhancing your experience with Laravel Tablar: Standard Form Components: Includes text fields, radio selections, checkboxes, and secure password inputs, along with datepicker & custom buttons. Tailored for efficient data entry and user interaction. Advanced Dropdown: Includes both standard and dependent Dropdown, suitable for dropdown data relationships. File Upload with On-the-Fly Image Editing: This feature not only simplifies the file uploading process but uniquely offers on-the-fly image editing capabilities, adding a layer of convenience and efficiency to your workflow. Optimized Data Tables with Export Options: The data table component not only organizes and displays information but also enables data export in formats such as CSV, XLS, PDF, and HTML, catering to diverse data analysis and reporting needs. Rich Text Editor with File Upload and Browser Features: Enhance your content creation with an editor that supports seamless file uploads. It includes a file browser feature, ensuring a comprehensive and uninterrupted content creation process. Responsive and Customizable Design: Each component in the Tablar Kit is built to be fully responsive, ensuring compatibility with various screen sizes. Moreover, customization options abound, allowing you to align each component with your application's theme, including support for dark mode. The Tablar UI Kit provides Laravel Blade components and the required JavaScript code for components to function. For example, you can easily add date pickers, file uploads, WYSIWYG editors, and more using premade components to your Tablar dashboards: {{-- Datepickers --}} <x-flat-picker name="admission_date"></x-flat-picker> <x-lite-picker name="admission_date"></x-lite-picker> {{-- File uploader --}} <x-filepond name="profile_image"/> {{-- Jodit editor (https://xdsoft.net/jodit/) --}} <x-jodit name="editor"></x-jodit> {{-- More at https://tablar.ebuz.xyz/docs/11.0/components --}} You can learn more about this package, get full installation instructions, and view the source code on GitHub. Also, you can view the Tablar Kit documentation to get familiar with the UI components. This package requires the Tablar Laravel Admin Template, which you can learn about here. The post Tablar Kit: UI Components for Tablar Admin Dashboards appeared first on Laravel News. Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.

Easily create complex database queries with the Query Enrich Package
Easily create complex database queries with the Query Enrich Package

Laravel Query Enrich is designed to easily create complex database queries in Laravel without having to write complicated SQL code. Here are some examples taken from the readme: Example of fetching orders placed in the last 7 days With Laravel Query Enrich $recentOrders = DB::table('orders') ->where(c('created_at'), '>=', QE::subDate(QE::now(), 7, Unit::DAY)) ->get(); Without Laravel Query Enrich $recentOrders = DB::table('orders') ->whereRaw('created_at >= NOW() - INTERVAL ? DAY', 7) ->get(); Raw Query SELECT * FROM `orders` WHERE `created_at` >= NOW() - INTERVAL 7 DAY; Using the avg function for grabbing the average monthly price for oil and gas With Laravel Query Enrich $monthlyPrices = DB::table('prices') ->select( QE::avg(c('oil'))->as('oil'), QE::avg(c('gas'))->as('gas'), 'month' ) ->groupBy('month') ->get(); Without Laravel Query Enrich $monthlyPrices = DB::table('prices') ->select(DB::raw('avg(`oil`) as `oil`, avg(`gas`) as `gas`, `month`')) ->groupBy('month') ->get(); Raw Query select avg(`oil`) as `oil`, avg(`gas`) as `gas`, `month` from `prices` group by `month` Using an exists query With Laravel Query Enrich $authors = DB::table('authors')->select( 'id', 'first_name', 'last_name', QE::exists( Db::table('books')->where('books.author_id', c('authors.id')) )->as('has_book') )->orderBy( 'authors.id' )->get(); Without Laravel Query Enrich $authors = DB::table('authors') ->select( 'id', 'first_name', 'last_name', DB::raw('exists(select * from `books` where `books`.`author_id` = `authors`.`id`) as `has_book`')) ->orderBy( 'authors.id', ) ->get(); Raw Query select `id`, `first_name`, `last_name`, exists(select * from `books` where `books`.`author_id` = `authors`.`id`) as `result` from `authors` order by `authors`.`id` asc Getting a full name using concatws With Laravel Query Enrich $authors = Author::select( 'first_name', 'last_name', QE::concatWS(' ', c('first_name'), c('last_name'))->as('result') )->get(); Without Laravel Query Enrich $author = Author::select( 'first_name', 'last_name', DB::raw("concat_ws(' ', `first_name`, `last_name`) as `result`") )->first(); Raw Query select `first_name`, `last_name`, concat_ws(' ', `first_name`, `last_name`) as `result` from `authors` Check out the documentation for complete details and view the package on Github. The post Easily create complex database queries with the Query Enrich Package appeared first on Laravel News. Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.

Introducing the Context Facade in Laravel
Introducing the Context Facade in Laravel

Laravel added a new Context service to define contextual data to the current request. Context data is included in all log entries for that request, and queued jobs will also retain that same data. Using contextual data allows you to easily trace back code execution for a given request and any distributed flows in your application: // In a middleware... Context::add('hostname', gethostname()); Context::add('trace_id', (string) Str::uuid()); // In a controller... Log::info('Retrieving commit messages for repository [{repository}].', [ 'repository' => $repo, ]); Http::get('https://github.com/...'); /* Log entry example: [2024-01-19 04:20:06] production.INFO: Retrieving commit messages for repository [laravel/framework]. {"repository":"laravel/framework"} {"hostname":"prod-web-1","trace_id":"a158c456-d277-4214-badd-0f4c8e84df79"} */ Contextual data also supports concepts like stacks, where you can push data to the same context, effectively appending data: Event::listen(function (JobQueued $event) { Context::push('queued_job_history', "Job queued: {$event->job->displayName()}"); }); Context::get('queued_job_history'); // [ // "Job queued: App\Jobs\MyFirstJob", // "Job queued: App\Jobs\MySecondJob", // "Job queued: App\Jobs\MyThirdJob", // ] If you'd like to learn more about this feature, check out the Pull Request description. Hat tip to Tim MacDonald, who created this feature for the framework! The post Introducing the Context Facade in Laravel appeared first on Laravel News. Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.