ochirach

ochirach

Member Since 10 Months Ago

Experience Points 1,050
Experience
Level
Lessons Completed 3
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

19 Jul
4 months ago

ochirach left a reply on Yajra Datatables With Styled Results

Hi,

Many thanks for the solution. I've done some more research on the issue and the yajra plugin does have method for this called 'editColumn'.

Documentation https://yajrabox.com/docs/laravel-datatables/7.0/edit-column#closure

It allows for me to move my style formatting (based on results) code here with little to no impact on the < 1 second speeds!

Thanks

ochirach started a new conversation Yajra Datatables With Styled Results

Hi,

Version: Datatables 7.0 | Laravel 5.4

After browsing the issues I have managed to convert my datatable logic from Collection based to Query based due to the significant performance improvement (i'm now getting < 1 second with query based from the 3-5 seconds with collection based).

My ISSUE now is that the custom formatting of query results I implemented prior cannot be maintained as the query does not user '->get()' to access the results.

Example scenario of the issue: I used to check if the user was an admin, editor, guest, etc then format the style of the user.role query result with different coloured labels to represent the role. Afterwards I add this to the collection then return to view for better readability of the table results.

Is this formatting possible with query based datatables (now that the ->get() has been removed)?

10 Jul
5 months ago

ochirach left a reply on DB Transactions Query Looping Alternative

Great. Had a detailed look at bulk inserts and it seems to be the better option

08 Jul
5 months ago

ochirach started a new conversation DB Transactions Query Looping Alternative

Hi,

Version: 5.4

Method: Query Builder after storing the .csv as an array $headers for columns, $data_rows for the data

Aim: I want to add users phone numbers via a .csv file to my database. Problem: Is there a better method other than looping through each row?

The entries can be up to 5000 users which results in 5000 insert queries. To ensure all are added at a go I have setup the insert process to run within a transaction.

Below is a simplified version of the code:

DB::transaction(function() use ($request, $headers, $data_rows) {

foreach ($data_rows as $row) { // loop through each row

    DB::table('user_phone_numbers')->insert(
                    [
                        'user_id' => $row[$user_index_from_csv_here], 
                        'number' => $row[$user_number_from_csv_here], 
                        'created_at' => date("Y-m-d H:i:s"), // now
                        'updated_at' => date("Y-m-d H:i:s"), // now
                    ]
                );

} // end foreach

});

29 Jun
5 months ago

ochirach started a new conversation Generate Url From Controller To View

Hi.

Version: 5.4

How can I send a full url of a route from the controller to the view?

e.g from

$user_url = "\users\[email protected]";

to

$user_url="http:://www.site.com/.........";

I want to display specific form actions depending on various user demographics by dynamically using the appropriate action url

27 Apr
7 months ago

ochirach left a reply on Bootstrap Modal Form For Managing Data (avoid Passing Ids To View)

LOL! I hear you. Once I get a full grasp of Laravel I want to develop applications that handle delicate information using this Framework.

It's (the paranoid strategy of the question posted) a tough direction for developers to take especially with the multitudes of applications that are to be developed and managed.

My stance: To start with I'll go with the common process as mentioned by @Cronix above then in future applications (once the comfort with Laravel is reached) i'll have to go with managing each item on an edit/delete view to satisfy my paranoia.

Thanks friends

ochirach left a reply on Bootstrap Modal Form For Managing Data (avoid Passing Ids To View)

@jlrdw

"What? This data is only in one browser, where the logged in user is sitting. And if they leave the computer they should log out. That screen (browser) isn't available to anyone else."

Remember, I am assuming a scenario where the human mistakes are possible. In my experience, there are times when someone may 'forget' to log out as they leave their desk briefly i.e to physically go away from their currently logged on machine.

I aim to prevent an attack where the attacker is at the physical location of the admins machine. And if the attacker is in fact an employee (think disgruntled employee) then they will be unsuccessful.

P.S I greatly appreciate the patience you are having in assisting be, I feel we are almost there

ochirach started a new conversation Passing Variables To Form::open(['action' => ['[email protected]', $id_variable_here]])

Hi,

Laravel 5.4

Is it possible to pass data to the form parameter from Javascript?

I have a users table with edit/remove buttons for each user. Using Bootstrap Modals, a users information can be edited using the form that is present on the Modal.

I need to pass this via the $id required by the update method in the controller.

Each time a different user is to be edited/removed, this variable will be updated to the user selected.

Note: I already got every other requirement working; just need the id to be passed dynamically

Form::open(['action' => ['[email protected]', $id_variable_here]])

ochirach left a reply on Bootstrap Modal Form For Managing Data (avoid Passing Ids To View)

I am assuming a scenario where an admins account may be compromised (i.e stepped out of the machine giving time for an attacker to manipulate using their machine).

If I can prevent even the admins account from doing this, then this vulnerability is closed

ochirach left a reply on Bootstrap Modal Form For Managing Data (avoid Passing Ids To View)

Yes. This is the idea but users ids are all sent to the view.

In your foreach loop you entered the user_ids for the data-whatever properties. This is the common way which I see as a security risk since the user_id can be manipulated as all of them can be accessed in the browser console which could be modified the markup before sending it i.e clicking the remove user button for Jane Doe then altering user_ids to corrupt database data.

It seems it is not as simple to avoid not sending the users ids to the view. I was intending to use a sort of predictable input solution but this would require a redirect to an edit/delete view for the solely selected user rather than handling it within the same view as the table.

From my search for a solution, all results use this method of passing all ids to view via 'hidden' inputs which are easily altered in browser console.

ochirach left a reply on Bootstrap Modal Form For Managing Data (avoid Passing Ids To View)

Note: In the scenario above we are managing users using a table that displays all users information. Therefore, to manage the correct user, each row needs to be identified using an id to avoid writing over another users data.

Whenever the edit/remove button for a row is clicked, it will pop-up the modal (which contains a form already pre-filled with the row(user) data) for the respective user.

My concern is that I will have to send all users details with their user_id for identification which is a security risk that I feel can be avoided. This alternative is what I am interested in

ochirach started a new conversation Bootstrap Modal Form For Managing Data

HI,

Laravel 5.4

I have a table (say users table) with the following fields:

Names, Birthday, National ID, Edit, Remove

...and I want to use Modals to manage the Edit and Remove features. On click, the edit button for the selected row will edit that users data in the pop-up modal already pre-filled with the active information.

What is the safest method of passing the 'id' of the record being updated? I am not comfortable with passing the id for all users to the view for security reasons.

Thanks.

Similar case where solution was to stick with sending all ids to view:

https://stackoverflow.com/questions/38201925/laravel-how-to-pass-id-to-modal-box-for-editing?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

ochirach left a reply on Custom 401 Error Page

Thanks. No need as the default Laravel solution is satisfactory for my application

21 Apr
7 months ago

ochirach left a reply on Passing Sizeable Data To View (Best Practice)

Great! Thanks friend

...but are you a good coder though? :)

ochirach started a new conversation Custom 401 Error Page

Hi,

Version: 5.4

I want all by error views to match the application theme, rather than a white page with the error text on the top-left.

It seems that doing this for 404 errors is as simple as creating a file in views/errors/404.blade.php. This works fine.

But the same does not occur for error 401. Is it best practice to customize this 401 error page?

If so, what extra steps are required as I assumed it was as simple as creating a new error file.

Thanks

17 Apr
7 months ago

ochirach started a new conversation Passing Sizeable Data To View (Best Practice)

Hi,

Version 5.4

What is the best practice method of passing data from the database (via controller) to the view in Laravel?

I have a 'user' view that displays all kinds of user information.

Names, Birthday, address, numbers, etc

Should I cram all this eloquent database logic to a single method (public index(){}) then store all in arrays relating to the data types (i.e names array, addresses array) as this information is to appear onload?

Thanks

13 Mar
9 months ago

ochirach left a reply on Form Validation: Is Full Stack Validation Best Practice?

User experience is definitely something that I need to be slick as they will be updating data regularly. Full stack validation it is.

Thanks

09 Mar
9 months ago

ochirach started a new conversation Form Validation: Is Full Stack Validation Best Practice?

Hi,

Is it best practice to have both front and back end form validation for applications where users are regularly posting information? Or is Laravel (back-end) validation good enough on its own?

In my case users will have to enter dates using the format dd/mm/yyyy (I can do this with a javascript but should I) only, all inputs should be stripped of all extra whitespace and I will use predictive input checks for all drop-down selections to name a few validation tests.

05 Mar
9 months ago

ochirach left a reply on Using PHP Functions In View

Great! There are about 3 methods from the link but creating the Helper and recording in composer file seems the best solution. Thanks

ochirach started a new conversation Using PHP Functions In View

Hi,

I have a php function (named 'weeks_in_month') that calculates and returns the number of weeks in a month (parameters: month,year). I want to use this functions result within the view i.e

$number_of_weeks_in_current_month = weeks_in_month($current_month_number, $current_year);

There are $number_of_weeks_in_current_month week(s) in this month

How can I go about this? Is a new controller needed for this? This views controller currently has the 1 function to return the view from a get request.

19 Feb
9 months ago

ochirach left a reply on Ajax-Heavy Application

Sounds like this covers all my requirements. Will implement after reading on the subjects

Thanks a bunch.

18 Feb
9 months ago

ochirach started a new conversation Ajax-Heavy Application

Hi,

I am developing an application that will require regular real-time Ajax calls for such:

  • refresh all notifications (i.e n unread reports, n pending requests, etc)
  • manage personal calendar (view/add/delete/update)
  • update graphs and charts so that no refresh is required to monitor data

Being that Laravel is server-side, is it best to also use a front-end framework to exclusively manage this? Or is there an inbuilt feature Laravel includes for this?

17 Feb
9 months ago

ochirach left a reply on New Alertify Package For All Your Alerting Needs

Great! Will try it out.

Was using alertify js on previous projects and want to integrate to laravel for notifications

14 Feb
10 months ago

ochirach left a reply on Large Scale Project Design

Many thanks to all of you for the various guides. Normally I setup my directories to give myself a mental map of the project as I build it piece-by-piece.

I have gone through various tutorials on YouTube (though they are the common Laravel blog tutorials) and I am using one as a step-by-step guide on my project start to get the app initialized.

Way forward: I'll start with getting all access levels dashboards up and running then as @martinbean mentioned, i'll list all entities (be it Calendar, Notifications, Charts, etc) to capture the entire scope of controllers. Once I reach this milestone i'll play around with various solutions to arrange the various app sections.

Definitely a Big dirty learning curve

12 Feb
10 months ago

ochirach started a new conversation Large Scale Project Design

VERSION: LARAVEL 5.4

Hi, I want to design a large scale application which is similar to below and need advice on how I should design the project in Laravel 5.4

Application type: School Application

Access Levels (with brief summary of abilities): • Teachers o Calendar, View all students, analyze student progress, etc • Students o Can view calendar, past papers, etc • Parents o Can view their students (i.e children) progress be it test scores, calendar, school fees, etc • System Administrator o Responsible for managing staff access on system • Headmaster o Can manage teachers i.e review class performance, calendars, schedule events, etc • Finance o Manages invoices, fees, etc

Example Folder structure (that I would normally use for php only project):

Folder Depth 0

  1. Dashboard
  2. Calendar
  3. Finances
  4. Students

Folder Depth 1

  1. Student Fees
  2. Classes

Folder Depth 2

  1. School Fees
  2. Bus pass
  3. Primary
  4. Secondary

Folder Depth 3 Year 1 Year 2 Year 3 Year … Year … Year … Year 11 Year 12 Year …

As shown above in access level summaries, various access levels will have access to past papers, all have access to calendar and homepage, only finance can view/update/create/delete all invoices, etc

What is the recommended way to convert this concept to a MVC format for Laravel project (i.e a school application) that has these requirements? Should I simply create this exact folder structure within the views? And for routes, will I have to wrap each access levels pages within conditionals for each access level?

NOTE: I am moving from a plain PHP project to a php framework project therefore I am used to just creating the folders for each section as shown above