douglasakula

douglasakula

Nairobi

Hire Me

Member Since 1 Year Ago

Experience Points 37,900
Experience
Level
Lessons Completed 305
Lessons
Completed
Best Reply Awards 11
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 Jan
1 day ago

douglasakula left a reply on Limit A Client From Doing A Set Action More Than A Set Limit (without Users)

Probably using throttle middleware to limit requests for the set action

18 Jan
2 days ago

douglasakula left a reply on What Is The Main Purpose Of Developing REST API?

@msoft To provide an interface that will enable systems to communicate and exchange data in a unified format.

An example can be an ecommerce android app for amazon. The android app would need data on items on sale that are hosted on a remote server. An api becomes the interface through which the android app can request the data on items on sale from the remote server. Same way when an order is made through the android app - the API becomes the interface through which the order is posted to the remote server

douglasakula left a reply on Read Codeigniter External Folder From Laravel App

@mrweb

Not sure how the CI project is coupled. I would try having the CI project as a library within laravel app. So all your CI models, helpers etc would be available in your laravel app through $CI->foobar_model etc incase of a model - then you access the old CI data. Looking at the CI code as a library / plugin with all that logic that you are reusing in your laravel app could be a great place to start. You can have a CI instance within laravel app. Though it requires lots of testing - at times rewriting some things within laravel since it will look like its implementing the library

17 Jan
3 days ago

douglasakula left a reply on Validation

@kshitizmittal

Do you have a sample file name that could be a double extensions - that's probably a good place to start. ( Do you mean validate a file that can be both a gif and a jpg. )

douglasakula left a reply on Split A Multidimentional Array

@jaydee84

Try to think along this lines:

Your input array

$array[0] = [
        'TextKey' => "bla-bla1",
        'Translation' => "Apple"
      ];
        
      $array[1] = [
        'TextKey' => "bla-bla2",
        'Translation' => "Anchor"
      ];
      
      $array[2] = [
        'TextKey' => "bla-bla3",
        'Translation' => "black"
      ];
      
      $array[3] = [
        'TextKey' => "bla-bla4",
        'Translation' => "blue"
      ];
      
      //Group the requests by their account_id
      $groupedArray = $this->groupAssociated($array, 'Translation');

      dump($groupedArray);
      
      dd($array);

Your groupAssociated array function

function groupAssociated($array, $key) {
        $result = array();
        foreach($array as $value) {
            $result[substr(($value[$key]), 0, 1)][] = $value;
        }
        return $result;
    }

It should give you results close to what you are looking for or probably lead you to the right direction

douglasakula left a reply on I'm Trying To Get Css Style File According To Language In Laravel.. But Not Working

@nagm_star

What do you see when you view page source in your browser. Does the href translate to a css file within the directory ? - That looks like a good place to start looking from

12 Jan
1 week ago

douglasakula left a reply on Game Cms

@mikkelbfriis

sounds good enough. probably having the table named avator_player in following naming convention for pivot tables.

douglasakula left a reply on Online API Route Doesn't Load Data.

@imeda :) makes sense. Noted with thanks

douglasakula left a reply on Online API Route Doesn't Load Data.

@anonymouse703

Best place to start is server error logs. You could be missing an extension that is installed in your local server or your remote laravel installation needs a package update or install thats already installed on your local server. To rule out laravel packages - you can run composer update on remote server. To rule out server extensions - which looks the most probable cause for me - enable debug on remote host to see if there are any errors - and check server logs as well - there must be something somewhere.

If on apache with root access - you can type this in terminal to view apache error logs

sudo su

tail -15 /var/log/apache2/error.log

douglasakula left a reply on Protect Direct Access To Public Folder (folder Name: "services") But Allow Sitexx.com/services Url

@nitinsridar

One way is to have the files in services folder with 0600 permission and make them owned by web server (www-data) alone or any other user for that case.

Then have a route that defined services e.g.

Route::get('/services', '[email protected]')->name('services');

So to protect direct access to public folder - change permissions and ownership of files and to allow access to services url define a route for that. They are 2 distinct things not related - thinking along this lines - you should be able to pull it off.

douglasakula left a reply on Website Hosting Automation

@aquinobr

You can also create a subfolder by mkdir command - http://php.net/manual/en/function.mkdir.php

But if what you want is the user to be able to create their own files or website layout - then that's a broad topic that could take a totally different direction.

11 Jan
1 week ago

douglasakula left a reply on Mysql Program With Live Update Of Tables

@learner1982 Looks like you are asking for a database browser (DBMS) that autorefreshes. I use phpmyadmin and to check if data has changed - I always refresh the whole thing. I don't think there is one that will autorefresh - at least that I know of.

IMO. You could hack simple solutions - for example with phpmyadmin -since its open source, made from php and hosted locally - but the hack would probably not be worth the effort compared to the alternative of refreshing.

douglasakula left a reply on Launching Laravel On A VPS

@qwertynik

or at times the storage folder is not writable and you have to assign 0777 permissions

douglasakula left a reply on Database Layout Design

@jaheller

Tables and columns names at times can always be right or seem right when looked in isolation. Since you question is whether the design is a good idea or if a different idea is better. I have a suggestion I use to design the database. I look at the entities that make up the system am trying to build e.g. packages, feedbacks, users, orders, etc. I then look at the relationship between the entities - e.g. one user has many packages, one user has many orders, etc. I normalize the entity data then then create pivot entities where necessary like feedback_package. Eventually my entities will translate to models and the relationship to eloquent relationships. The models are classes I view as objects and can make them do every imaginable behaviour - say I want "some kind of average for users" - I would have a function within the user model that does this say "deliveryTypeAverage".

Bottomline thinking of database design as you would think of real world objects gives you flexibility and allows you to "breath life" to your application because everytime you think of a feature you need to add - you clearly "see" where you are adding it - in most cases it translates to a function within the class, or a different class you can use, extend etc

douglasakula left a reply on Taking TWO Variables From Inside A Foreach And Pass To A Modal

@rafaelmunoznl

I would try this approach.

@foreach ($images as $key => $image)
<div class="the_thumbnail">
    <img class="image" src="{{URL::to('/img/' . $image->slug ) }}" alt="{{$image->image_name}}" >
    <div class="overlay">
        <button type="button" class="btn btn-block btn-primary" data-toggle="modal" data-target="#modal_{{$key}}" data-imagename="{{$image->image_name}}" data-slug="{{$image->slug}}">
            {{$image->image_name}}
        </button>
    </div>
</div>
@endforeach

An id of modal_{{$key}} would ensure you have / call unique modals when you do - the buttons would also be unique. Currently it looks like the modals are referring to data on the last element of the foreach items.

The data target for the button would change as well to have the {{$key}} variable.

The way I would do it is modals being packaged within a foreach and buttons would fire them when they are required. ....Or the way I look at it you need at least a key so your modal isnt always populated by the last item in the foreach array.

10 Jan
1 week ago

douglasakula left a reply on Anlutro/l4-settings Errors

@jucan When you browse your applications database via phpmyadmin / other database management software - do you see the settings table

douglasakula left a reply on What Does 'as Aggregate' Mean When Performing Sum()?

... or rather - eloquent will name the results of the aggregate function query as "aggregate" if a name is not supplied - should you wish to reference this aggregated results in a case where the aggregate result is not the only results being returned

douglasakula left a reply on Anlutro/l4-settings Errors

@jucan

Do you have a table called settings in your application then ?

douglasakula left a reply on Method Illuminate\Database\Eloquent\Collection::join

@davy_yg

Try this / not calling join on all since at the end get() will give you the collection

$data2 = ApplicationModel::join('tb_detail', function ($join) {
                $join->on('detail_id','=','detail_id');
               })->get();

douglasakula left a reply on Anlutro/l4-settings Errors

@jucan

You should probably run php artisan migrate. It could be you are missing a table or tables in your application

09 Jan
1 week ago

douglasakula left a reply on Can Someone Explain Me This Error

@socieboy

Two possible reasons. 1. You have inefficient code or 2. you need to scale your application / infrastructure - if the code is efficient in the first place.

douglasakula left a reply on Why Is Sum Of 0.29 Returned Like This - 0.28999999165534973?

@martinzeltin

precision I think - what data type is the bonus_sum column in your database ? - int, decimal,varchar ?

Could be eloquent manipulates this differently based on above database data type different from raw sql query

douglasakula left a reply on What Kind Of Procedure If I Want To Develop - Sales, Profit, Report ?

@towhid

reports would make heavy use of eloquent relationships - you would need tables for sales, profits, countries, agents. This would be the entities in your system / models and would make the bulk of your report generation But this would be just a tip of the iceberg. Assuming you still need to do system analysis and design, database design etc.

douglasakula left a reply on Laravel Log Doesn't Work.

@anonymouse703 on ubuntu - I would navigate to where the folder is via terminal and type in ls -lah

On windows you can view / modify the permissions on filezilla or view the permissions via cmd as well.

It just a property of the files and folders.

08 Jan
1 week ago

douglasakula left a reply on Laravel Log Doesn't Work.

@anonymouse703 - probably permissions on the storage folder preventing laravel from creating new file. Check that permissions is 0777

douglasakula left a reply on Validate Multiple Unique Columns

@cjustado

probably rule exists - https://laravel.com/docs/5.7/validation#rule-exists

If you have the unique constrains in you database.

douglasakula left a reply on How To Update A Table Without Primary Key?

@nabilunfarhanun

Yes. If above is not working though I think it should work as it is fetching a record / object - then the other option is raw queries.

Just confirm that dd($minyuko) is indeed an object. Could be its getting an empty result set and hence reason it cant be updated.

douglasakula left a reply on Is There Any Way To Search On Encrypted Data On Database

@mitismirza

If encyrption gives different values for the same string - then its a red flag already.

Solution above focuses on the security aspect of the application. I would think other aspects of account balance are better managed when the account balance is a raw amount as opposed to an encrypted amount. For example you may need to increment the user account balance, decrement it, group by user balance, search as you have tried etc. - All this operations becomes hard when the values are encypted and unless you are on top of the encryption - it can result in logical errors.

In my opinion - I would think of security as a whole - and secure other layers of the system but leave the data as a raw amount. - Say secure the access to the database with strong password and users with limited privilidges to the database. Secure the network, secure the server etc. I would go for encryption as the last element when am not confident with the other security layers where the application sits.

This is just so I can easily manipulate my account balance in its raw form

05 Jan
2 weeks ago

douglasakula left a reply on Where Do I Set A BASE_URL With A Controller?

@swindlenswoon

Is it none of the links or the links to the assets (css, js and images) ?

28 Dec
3 weeks ago

douglasakula left a reply on Override ValidationException

@codingprogress

Sure you can do this.

You may pass the custom messages as the third argument to the Validator::make method.

https://laravel.com/docs/5.7/validation

Check "Custom Error Messages".

douglasakula left a reply on Check If Language Is English

@webiondev123

I would think along the lines of google translate and if they have an open api that can take text and give the language. I guess it can be one of the most accurate implementations if it exists.

Check if this will give you more leads.

https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/translate

douglasakula left a reply on Optimising Video For Faster Load

@eddy1992

Probably using youtube or vimeo to host the video - they have spent time worrying and making all the optimisations you will be looking to do.

But if for whichever reason - you must host it yourself and use laravel to optimize performance. Then it has to be the least size you can get that wont compromise the quality.

douglasakula left a reply on Users That Can Create Another Users And Restrict Some Functionality On Website

@4unkur

For packages checkout - https://github.com/Zizaco/entrust

Looks like a popular package having the functionality in question

douglasakula left a reply on Users That Can Create Another Users And Restrict Some Functionality On Website

@4unkur

At a basic level - its all CRUD (Create, Read, Update, Delete) on a resource / resources. A user is a resource, fund is a resource. Laravel provides for policies where you can define who has the ability to do CRUD actions on which resource.

So if you have a users model, you could create a users policy that defines which users / usertypes can for example create other users - then whenever that user logs in he is the only one that can perform those actions you have specified. Same thing with funds - your fund model will have a corresponding fund policy that defines which usertypes can do what.

Check below resources for additional information on gates and policies.

https://laravel.com/docs/5.7/authorization#gates

There are several screencasts on this well on laracasts.

As for packages - I havent used any that I can recommend - but its possible someone has wrapped resource manipulation within gates and policies that you can pull into your project.

27 Dec
3 weeks ago

douglasakula left a reply on Admin Dashboard

sb admin is good and looks decent as well.

https://startbootstrap.com/template-overviews/sb-admin-2/

douglasakula left a reply on Different Access

@vajid @reached

Great.

Makes sense now.

Thanks a lot.

douglasakula left a reply on Different Access

@vajid

Can you share even an online link on the guard that expounds on this.

douglasakula left a reply on Different Access

@vajid

If user enters url manually in address box - he remains the same user. The user object does not change across laravel Auth::user() remains constant the route changes but not the logic that determines what partial is displayed remains intact. The logic is purely based on the user object and not the url entered. The url can be the same but based on authenticated user property it includes a certain partial / respective partial

douglasakula left a reply on Need A Logical Help In View.blade File

@abdulbazith

Would you like a quick fix or would you like to implement a robust solution.

A quickfix would be doing a query to the sales tables - looping through the sales details and grouping the details with the hour

A robust solution would be breaking down your entities further. You currently have a "sales_details" entity - but from the information you are saving - I can see a customer entity (/Model / Object), sale entity, You could work with 2 tables a sales table and a customers table. Such an approach would allow you to move the "logic" as properties and methods to your model classes and look at them as objects. Quick fix looks at this as data - so you end up fetching data and putting all the logic in one controller

Back to the quick fix. It would go something like this

      //doing the querry
      $sales = Sales_details::orderBy('created_at','desc')->get();
      
      $sales_details = [];
      
      foreach ($sales as $key => $sale) {
        //total litres initialisation for all customers
        $sales_details[$sale->customer_name]["total_litres"] = 0;
        //total rate initialisation for all customers
        $sales_details[$sale->customer_name]["total_rate"] = 0;
      }
      
      foreach ($sales as $key => $sale) {
        //array of customer names grouped by the customer id
        $sales_details[$sale->customer_id]["name"] = $sale->customer_name;
        //this will give you an array of times for the customer - you can use Carbon/carbon to format the time to get the am and pm - can explain further
        $sales_details[$sale->customer_id]["time"][] = $sale->time;
        //sum up the the total litres grouped by customer id
        $sales_details[$sale->customer_id]["total_litres"] += $sale->total_litres;
        //sum up the the total rate grouped by customer id
        $sales_details[$sale->customer_id]["total_rate"] += $sale->total;
      }


So think along those lines. Once you pass your sales_details to the views - its something you can loop through and get the respective fields you like.

26 Dec
3 weeks ago

douglasakula left a reply on Writing A Software Proposal

@phpmick "Software Proposal" is generic and can mean a lot. To add to what @shez1983 has said the document you could be referring to could be a Software Requirements Specification document - and can get very detailed depending with objectives you want to achieve.

https://krazytech.com/projects/sample-software-requirements-specificationsrs-report-airline-database

If "Software Requirements Specification document " looks like the document you have in mind then you could further your search along those lines. There is plenty of resources on this.

douglasakula left a reply on Call To A Member Function Count() On Null

@davy_yg

By ensuring taking care of a null $data should it happen. In your case if there is no user with the email address in request. $data is null and doesnt have a count method on it.

On another note. I see the if else are doing validation.

You would have much cleaner code with this validation validation rules inbuilt in laravel - exists,confirmed, - at least from the two if else statements I can see above.

Exists would validate for if the email is within the database - https://laravel.com/docs/5.7/validation#rule-exists

Confirmed would validate if the password and password_confirmed match - https://laravel.com/docs/5.7/validation#rule-confirmed

douglasakula left a reply on Different Access

So that you could so something like

@if(\Auth::user()->type == "admin")
            @include("partials.admin_menu")
@else
            @include("partials.user_menu")
 @endif

In terms of "seeing" - such a solution could be pretty decent

douglasakula left a reply on Different Access

@davy_yg

Current user can be retrieved this way

$id = \Auth::user()->id;

douglasakula left a reply on Different Access

@davy_yg

I would have done it this way. But looks like we have some interesting ideas - guards & middleware. So am following this ...

If you already have usertypes or roles / property / function within your user to distinguish the two. Assuming both admin and staff are users and you have usertype as either admin or staff. ( Again - could be users or could be employees ...)

@if($user->is_admin())
       @include("partials.user_menu")
@else
        @include("partials.staff_menu")
 @endif

douglasakula left a reply on Send Bulk Email To Users

@webiondev123 - use dd($data['type']) and see whats pops out. I don't think there is any better way to check that - just check that the value you think should be "type_x" is actually "type_x". Can you also dd($data). Issue is in the data and not event the condition - its the input data - either misspelled, different type - could be an array of objects - am not sure - you could know better

douglasakula left a reply on Passing Data From Laravel To Nuxt App

@haizone

You need to create an API (Application Programming Interface). This will enable you to make server 1 communicate with server 2. An application in server 1 can send a message in any format to server 2. So server 1 would have an endpoint that sends message while server 2 would have another endpoint that receives the message and processes it as you would wish.

So you need to know in advance the 2nd endpoint you are sending data to. (It may require authentication - and that's fine)

douglasakula left a reply on Need A Logical Help In View.blade File

@abdulbazith

This goes back to the models. Its better handled at the model level than the view level. Trying to do it at the view level would be messy. Are you in a position to share more on the models you are using to fetch this data / relationships they have. From within the models - you can do a custom function called from a controller that will fetch the data and group it by hour / customer so that by the time you display to the view - its well formatted and all the view does is display the data.

douglasakula left a reply on Send Bulk Email To Users

@webiondev123 Can you first confirm you are entering the foreach loop ? I wouldn't expect email not to be sent - at least if it was working in the first place.

All we did was introduce a type property for the user object which we are using to query and wrapping the mail functionality within an iteration of the users.

So confirm this gives you something.

$users = User::where("type","X")->get();

dd($users);

douglasakula left a reply on Joins

@swapna

Create models for each of the tables if you have not done so and within the models define the relationships.

It would be great if you can specify the kind of relationship between your "entities" above. Say "one address has many candidate_contact_info" etc.

So back to your question - Create a model for each of your table and within the model class define the relationship with the other model / table / entity.

Check out this for relationships - https://laravel.com/docs/5.7/eloquent-relationships

Alternatively - you can do raw joins where you specify the tables you would like to join as you build your query. For (raw) joins checkout - https://laravel.com/docs/5.7/queries#joins