Laravel Module 

DAY 3

Session

Alert Using Session

When you retrieve an item from the session, you may also pass a default value as the second argument to the get method.

index.blade.php

ScheduleController.php

File Storage

  1. Create migrations to alter trainings table

  2. Add attachment input in views

  3. Create Symbolic Link

  4. Check in Controller if the input has attachment and update row with the file name.

  5. Delete the file on storage if the row will be deleted

  6. Open attachment file

Create Migrations to alter table

php artisan make:migration alter_schedules_table_add_attachment

Add attachment input in views

Create Symbolic Link

The public disk is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public.

To create the symbolic link, you may use the storage:link Artisan command:

php artisan storage:link

Check Controller

Check in Controller if the input has attachment and update row with the file name

Delete

Delete the file on storage if the row will be deleted

ScheduleController.php

Open Attachment

show.blade.php

Search

  1. Create form to input keyword

  2. Query the keyword that match with title

Search - Form

Using GET method to named route schedule:index

Search - Index Method

Check if there is keyword, if there is keyword on query string, run query to search column where like title.

If no keyword, the method will return collection rows from trainings table.

Search - Pagination

The paginate method automatically takes care of setting the proper limit and offset based on the current page being viewed by the user and append with keywords.

resources/views/schedules/index.blade.php

app/Http/Controllers/ScheduleController.php

Integrating Bootstrap Themes from startbootstrap

Choosing a Templates

Integrate Bootstrap with Blade templating

Integrate with Bootstrap template

• Create a folder on resources/views named admin

• Create a folder on resources/views/admin named includes and layouts

• Create files on resources/views/admin/includes named:

footer.blade.php

sidebar.blade.php

navbar.blade.php

• Create files on resources/views/admin/layouts named:

main.blade.php

Adding Assets

• Move all assets to public path.

• Copy index.html to resources/views/admin/layouts/main.blade.php

• Change local call assets using asset

From:<script src="js/scripts.js"></script>

To:<script src="{!! asset('js/scripts.js') !!}"></script>

  1. Find <footer> to </footer> tag then cut and paste to footer.blade.php [email protected](‘admin.includes.footer’) on the cut area
  1. Find <navbar> to </navbar> with top navbar class then cut and paste to navbar.blade.php put @include(‘admin.includes.navbar’) on the cut area
  1. Find <navbar> to </navbar> with sidebarclass then cut and paste to sidebar.blade.phpput @include(‘admin.includes.sidebar’) on the cut area
  1. Find <main> to </main> tag and replace the content only with @yield(‘content’)

Go to resources/views/trainings/

Changes on all blade file

From: @extends(‘layouts.app’)

To: @extends(‘admin.layouts.main’)

Update NavBar

Update Sidebar

Scroll to Top