Member Since 2 Years Ago

Experience Points 31,870
Experience Level 7

3,130 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 300
Best Reply Awards 1
Best Reply
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.


    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.


    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

17 Jul
1 day ago

cservices started a new conversation Saving Errors To DB / Custom Error Messages

Im using Laravel 5.4. In my app I want to log to the database error messages created by specific methods. I also want to display a custom message to the user and refer them back to a specific page once they acknowledge the error.

Are there any tutorials out there to help explain how I might do this? Any thoughts or advice on the direction to go?

Some people in chat suggested some third-party stuff, but that is not an option where I work. It all has to be done internally.

Thanks in advance for your help.

21 Jun
3 weeks ago

cservices left a reply on Saving A New Image

I looked into Intervention and it's actually pretty good for what I need. Simplified things tremendously.

Thanks for your help. I will still be looking into things you folks have pointed out. I still want to know how to do it the long way.!

cservices started a new conversation Saving A New Image

I am creating a thumbnail image and am lookin to store it publicly.

Ultimately the path would be created in /storage/public/profiles/record ID/thumbnail_record id.jpg

I tried creating this with public_path() like this:

        $path_to_file = 'storage/public/profiles/'.$profile_id;
        $storage_path = public_path($path_to_file . "/thumbnail_$profile_id.jpg");

But I get an error: imagejpeg(/Users/cyj/websites/htdocs/member-profile-tool/public/storage/public/profiles/51/thumbnail_51.jpg): failed to open stream: No such file or directory

What is the best way to save a resized image that I need to access publicly?


18 Jun
1 month ago

cservices started a new conversation Custom Validation Message

I would like top create a more custom validation message. I do not need to rewrite or create a custom validation rule, just the message.

Any way to do this?

Thanks in advance.

cservices left a reply on Validating Dynamic Fields Using Array Naming Convention

I realized I was over complicating things with my use of array fields names. Since I was generating a unique name for each, there really was no need to name them that way. Changing this allowed the validation to work.

Thanks for your help.

17 Jun
1 month ago

cservices left a reply on Validating Dynamic Fields Using Array Naming Convention

@TRAY2 - Using your example I built the code to create the validation array. However, no matter how I do it, when any of the dynamic fields are present, it says it has no value, when I know it does.

To explain what the first part of this code is doing... I have a hidden field that keeps track of the index numbers. So, for example, it might have the values of "1,3,4"

The code turns this into an array in the controller method, to be used in the foreach to generate the field names for the validation to work.

Here is my validation code:

$form_channel_fields = array(); // Holds dynamic fields names
            if (isset(request()->profile_form_channel_ids)) {
                // Creates an array of index numbers
                $channels_field_nums = explode(",", request()->profile_form_channel_ids);

                // Creates individual array elements in key/value pairs
                foreach($channels_field_nums as $channel_num) {
                    $form_channel_fields["channel[$channel_num]['channel']"] = 'required';
                    $form_channel_fields["channel[$channel_num]['pub_date']"] = 'required_if:channel['.$channel_num.']["status"],==,4';

            // Typical Laravel associative array with validation codes
            $other_validated_fields = array(
                'first_name' => 'required',
                'last_name' => 'required',
                'job_title' => 'required',
                'classification' => 'required|not_in:none'

            // Merge $form_channel_fields and $other_validated_fields into $collected_validation_fields
            $collected_validation_fields = array_merge($form_channel_fields, $other_validated_fields);

            // Validate fields
            $this->validate(request(), $collected_validation_fields);

In case you are wondering, here is a dd() of the $collected_validation_fields array using my index example of "1,3,4":

array:10 [▼
  "channel[1]['channel']" => "required"
  "channel[1]['pub_date']" => "required_if:channel[1]["status"],==,4"
  "channel[3]['channel']" => "required"
  "channel[3]['pub_date']" => "required_if:channel[3]["status"],==,4"
  "channel[4]['channel']" => "required"
  "channel[4]['pub_date']" => "required_if:channel[4]["status"],==,4"
  "first_name" => "required"
  "last_name" => "required"
  "job_title" => "required"
  "classification" => "required|not_in:none"

I keep the dynamic fields separate from the non-dynamic for my own sanity. I then merge them into one and feed it to the validation method. It works for the non-dynamic fields, but it does not appear to notice the dynamic field values. This is my error message:

The channel[1]['channel'] field is required.
The channel[3]['channel'] field is required.
The channel[4]['channel'] field is required.
The first name field is required.
The last name field is required.
The job title field is required.
The selected classification is invalid.

Thanks in advance for any help you can offer.

cservices started a new conversation Validating Dynamic Fields Using Array Naming Convention

I have a form where one section creates a new set of fields dynamically. So if one set of fields were created, the markup for the fields may look like this. Notice the naming convention for the "name" property in each.

<select class="custom-select profile_form_channel_selector" data-web_page_selector="web_page_selector_1" name="channel[1]['channel']">
    <option value="">Select a channel</option>
    <option value="1">Unassigned</option>
    <option value="2">Web Page</option>

<select class="custom-select" name="channel[1]['status']">
    <option value="3">Pending</option>
    <option value="4">Published</option>
    <option value="1" selected="">Unassigned</option>

<input type="text" class="form-control publication_date hasDatepicker" id="publication_date_1" name="channel[1]['pub_date']">

So if a set of these fields exists, the first validation would make sure that the "channel[1]['channel']" has a value.

Next, if the "channel[1]['status']" has a value of "4" (Published), then the "channel[1]['pub_date']" must have a value.

I'm not understanding how this would be coded in the validation area (Laravel 5.4). An example would be nice.

Thanks in advance

cservices left a reply on Making Better Forms And Use Of Laravel

@SNAPEY - Have not made use of "old" very much, but figured I needed to with the validation. I did not know/remember about the second argument that can be added.

Thank you for your input.

cservices left a reply on Making Better Forms And Use Of Laravel

@LOUDRIOT - Thank you for that.

No, I am not placing PHP for handling the form in the blade.

cservices started a new conversation Making Better Forms And Use Of Laravel

I'm a lone developer who is self taught. I have only places like this to ask questions and get answers. I'e been developing in PHP for years, and using Laravel for about the last three to four years.

My question is about building forms. Most of my work is on the backend, and I create all the interface for it as well as the processing code. But my blades that contain form code, mixed with template and PHP code, seems to get pretty crowded with the code I have to add to populate selects areas, radio/checkboxes and such.

Can you tell me the best method, or point to a tutorial, to create a form that is is not only used to store data, but to edit it as well? In addition, how to re-populate if the form validation fails?

Ive done this sort of thing many times before, but because the blades seem to get so crowded, I question if I am doing it correctly. - I am not using Vue or anything like it.

Thanks in advance for your advice.

18 Apr
3 months ago

cservices left a reply on Request Returns Last Row Only.

This is what I got after modifying the input to look like this:


<input type='text' class='form-control' name='edu[completed][]' placeholder='Year Completed'>
"edu" => array:5 [▼
        "application_id" => array:2 [▼
          0 => "16"
          1 => "16"
        "completed" => array:2 [▼
          0 => "1920"
          1 => "1921"
        "school" => array:2 [▼
          0 => "AAAAA"
          1 => "BBBB"
        "state" => array:2 [▼
          0 => "NC"
          1 => "OH"
        "degree" => array:2 [▼
          0 => "123"
          1 => "456"
17 Apr
3 months ago

cservices left a reply on Request Returns Last Row Only.

You need to add [] to the end of your inputs that will have multiple values.

For example:

<input type='text' class='form-control' name='edu[index][completed][]' placeholder='Year Completed'>

As ftiersch mentioned, you are overwriting the values and not creating an array of values. So the request will only see the last row of input.

02 Apr
3 months ago

cservices left a reply on Returning String Data From A Relationship Only

Thanks for the reply.

I understand your thoughts about naming. Which probably comes easy with experience. This was my first time using relationships, so I sort of went off rails naming-wise, since I wasn't even sure how it all worked. Hence also the question at hand.

Thank you again for your thoughts.

01 Apr
3 months ago

cservices started a new conversation Returning String Data From A Relationship Only

I have two tables.

  1. Types - Contains three fields: id, name and path
  2. Extensions - Among the fields is one named type_id - relates to the entry in Types

I first need to know the extension in order to get the path for the type. So I have a line of code in my method that looks like this:

// Get path
$ext = Extension::where('extension', $extension)->with('hasType')->first();
$path = $ext->hasType->path;

All I need is the path string. Is there a way to make a query using this relationship, but return only the path string of data I am seeking?

Looking to see what all I can do with these relationships.

Or do I need to create a separate method that does this for me, then return the string back to the method that needs it?

27 Mar
3 months ago

cservices started a new conversation New Entry In Model Method

This may sound like a dumb question but...

Say I am in a model (Foo) for a table named foo;

if I create a method that is going to create a new entry for "foo" do still write $foo = new Foo(); Or is there something else I can write that does the same thing, but without the need for the above?

Asking for a friend - LOL

15 Mar
4 months ago

cservices left a reply on Auto Model Binding? ? ?

That you all for the info. What you said mixed with watching this video answered a lot for me. https://laracasts.com/lessons/eager-loading

Thanks again, Cy

cservices started a new conversation Auto Model Binding? ? ?

So I have started venturing into Model Binding and really like what I can do with it. But I am seeing something that, for me anyway, seems like it is doing this binding without the need for ->with().

Example: I had some code that looked like this:

$data['this_assets_tags'] = AssetTag::where("asset_id", $id)

To access the tag data I would then do something like this in a loop:

@foreach($data['this_assets_tags'] as $tag)
                <div class="asset-view-tag-wrapper">
                    <div class="tag-name">{{ $tag->tag->tagname }}</div>

BUT, while making a few changes I ended up changing my code from above to exclude the ->with() method:

$data['this_assets_tags'] = AssetTag::where("asset_id", $id)

Lo and behold, the loop still displayed the tag name within

<div class="tag-name">{{ $tag->tag->tagname }}</div>

I cleared all caches and still it displayed the tagname.

I even did a die and dump on the variable in my class before and after it went to the view. dd($data['this_assets_tags']); and it dod not have the relationship in it.

So is this the way it's supposed to work? Can we actually write a query without the with() method and still have access to the methods within the models - even chained?

I hope this makes sense. And I hope someone can explain this, cause if this is not a bug, then it's a good feature, and good to know there is automatic chaining going on. What I don't get is what is happening to memory when our models have all these relationships built into them, and all that data is being accessed whether you need it or not.

Thanks, Cy

cservices started a new conversation Sorting Relationships

I have a query that looks like this:


Here is what it does: AssetTag (asset_tags) is a pivot table with only two columns. 'asset_id' and 'tag_id'.

First I get all the records for the asset record passed.

Next I get the tag data for each tag related to the asset

I then go back to the asset_tag table to get all the assets belonging to each found tag

Finally I get all the assets for each tag, excluding the asset originally passed

Problem: The page lists the assets that belong to each tag. The boss wants me to prioritize the results by listing the tags according to the amount of assets descending.

Files Related By Tag: Tag: Foo

  • Asset 1
  • Asset 2
  • Asset 3 Tag: Foobar
  • Asset 1

Is there a way to do this without having to break the query apart, writing each relationship individually?

cservices left a reply on Public Storage

This is the only way I can get it to work


cservices started a new conversation Public Storage

I'm in my development environment. I have set the artisan storage:link When I upload a file I do it like this:

$file->storeAs($path, $file_name, 'public');

When I look in finder (Mac) at '/storage/app/public' I see the created directory and all its content.

But, when I look at '/public/storage/' it does not show the same thing.

I cannot seem to access the stored files using storage_path() or public_path(). No matter what I do the end result is that the system can't find the file.

I am creating a DAM (Digital Asset Manager), so I must be able to read these files after saving them to disk so thatI can place content into DB for searching.

Thanks in advance for your help.

05 Mar
4 months ago

cservices started a new conversation Saving Created Image

I have an image in my public storage storage/app/public/alkami/backgrounds

I am adding text to the image and creating the image with imagepng($png_image)

Question is, how do I save this image to disc at storage/app/public/alkami

I'm using Laravel 5.4, as my PHP version is 5.something

Here is the full method I am using to create the text over image

public function generateImage()
        //Set the Content Type
        header('Content-type: image/png');

        // Create Image From Existing File
        $png_image = imagecreatefrompng(asset(request()->image_name));

        if (request()->font_color == "#fff") {
            // Allocate A Color For The Text
            $font_color = imagecolorallocate($png_image, 255, 255, 255);

        if (request()->font_color == "#000") {
            // Allocate A Color For The Text
            $font_color = imagecolorallocate($png_image, 0, 0, 0);

        // Set Path to Font File
        $font_path = '/fonts/Arial Bold.ttf';
        $font_path2 = '/fonts/Arial Italic.ttf';

        if (isset(request()->ad_text_one)) {
            // Set Text to Be Printed On Image
            $text = request()->ad_text_one;

            // Print Text On Image
            imagettftext($png_image, request()->ad_text_one_size, 0, request()->ad_text_one_left, request()->ad_text_one_top, $font_color, $font_path, $text);

        if (isset(request()->ad_text_two)) {
            // Set Text to Be Printed On Image
            $text = request()->ad_text_two;

            // Print Text On Image
            imagettftext($png_image, request()->ad_text_two_size, 0, request()->ad_text_two_left,  request()->ad_text_two_top, $font_color, $font_path, $text);

        if (isset(request()->ad_text_three)) {
            // Set Text to Be Printed On Image
            $text = request()->ad_text_three;

            // Print Text On Image
            imagettftext($png_image, request()->ad_text_three_size, 0, request()->ad_text_three_left,  request()->ad_text_three_top, $font_color, $font_path2, $text);

        // Send Image to Browser
        $image = imagepng($png_image);

        // Clear Memory
02 Mar
4 months ago

cservices left a reply on Accessing An Uploaded Public File

Figured out what I was doing wrong.

I was placing the first part of the path in manually /storage/app/public when all I needed to do start with "/storage/" then the path dynamically.

cservices started a new conversation Accessing An Uploaded Public File

I'm having an issue with uploaded files and accessing them.

I have set the storage:link.

When saving a file that has been uploaded do I need to specify public like this? $file->storeAs($path, $machine_file_name, 'public'); $path is a directory.

This saves the file at 'storage/app/public/dirname/filename.

I want to access this file in a couple of ways.

  1. To pass the path to a script - For example: I want to send an uploaded PDF file to a script that will parse it into a string and save that string to a database. I don't want to send the contents, only the path. The script will read the contents.

  2. I want to link to the file for download

Please advise how I can do this.

Thanks, Cy

27 Feb
4 months ago

cservices left a reply on First Time Model Binding

Thank you all very much. Very helpful and fun!

cservices left a reply on First Time Model Binding

Great! Thank you!

Now, can I expand that or nest another?

For example: Each extension can have many assets. If I wanted to add the count of how many assets belonged to an extension, and add that data to each extension object, how would I do that?

cservices started a new conversation First Time Model Binding

I'm trying out Model Binding for the first time, and am lost.

Here is what I have.

  1. A table called Types (Model Type)
  2. A table called Extensions (Model Extension)
  3. A Type can have many Extensions

I want to get a list of all Types, but in the same call get all the extensions for each Type object returned.

Make sense.

Thanks in advance. Cy

15 Feb
5 months ago

cservices left a reply on Form Action Dynamically Set

So far the only work-around I have found is to add a script to my @if statement for errors.

            $("#category_form").attr('action', '/category/update');

cservices started a new conversation Form Action Dynamically Set

If there is another way to do this, please advise.

I have a form where the action is set to action="/category/store"

Below the form is a list of items with an edit button next to each. When the edit button is clicked the data is sent to the form and the action is changed to action="/category/update"

The problem is if the form has errors and redirects the action is reset to action="/category/store"

Is there a way to ensure the action retains the update path on a redirect due to failed validation?

14 Feb
5 months ago

cservices left a reply on Axios Access

@WILK_RANDALL - I placed the import line at the top of my js file, which is located at /public/js/dam.js But get this error Uncaught SyntaxError: Unexpected identifier

The import line is the ONLY thing in the JS file at this time

cservices left a reply on Axios Access

@WILK_RANDALL - What file are you placing that in? Can I place it in /public/js/myapp.js ?

cservices started a new conversation Axios Access

I have never used Axios for AJAX and would like to give a whirl.

Every example I see using Axios uses it in conjunction with Vue, but I am not using view.

How do I access Axios for my app.

Is there another way to access it when using public/js rather than /resources/js ?

Thanks, Cy

25 Jan
5 months ago

cservices left a reply on Getting User Info

@MANELGAVALDA - I looked into docs and got my answer based on your help. Thank you!

cservices left a reply on Getting User Info

@MANELGAVALDA - Idid that and got an error: Call to undefined relationship [user] on model [App\Question].

cservices started a new conversation Getting User Info

I have a table ("questions") that contains a user_id to identify which user asked the question.

I want to collect ALL questions, but include some data (name for example) from the User table for each question collected.

Is there a way I can do this Laravel without writing a join query?

21 Jun
1 year ago

cservices left a reply on Trouble Saving Imagick Created File

I was able to get it to work to different ways, and I fixed the extension issue.

file_put_contents( public_path("storage/" . $file_storage_dir) . "/" . $file_name, $imagick);

AND $imagick->writeImage(public_path("storage/" . $file_storage_dir . "/" . $file_name));

The deal with the latter was that I found it written as writeImageFile() on some sites. Using the correct method always helps.

Thanks for all your guidance.

20 Jun
1 year ago

cservices left a reply on Trouble Saving Imagick Created File

I tried that.

                $imagick->resizeImage(200, 200, \Imagick::FILTER_LANCZOS, 1,1);
                $file_name = $filename_minus_ext . "-" . time() . "jpg";
                file_put_contents("public/storage/docs/pdf/" . $file_name, $imagick);

I just get an error message file_put_contents(public/storage/docs/pdf/phparchitect-2017-11-1529522507jpg): failed to open stream: No such file or directory

cservices started a new conversation Trouble Saving Imagick Created File

I am using Imagick to create a thumbnail image of a PDF page.

I’m getting everything to work, except I can’t figure out how to save the image.

$file['temp_path'] is the temp location of the PDF file that is being uploaded. I’m telling Imagick to use that version of the file to create the thumbnail image.

From there I’m going to a best fit of 200 x 200, and creating the image as a jpeg.

The raw image is kept in $imagick->getImageBlob() (I think), but I don’t know how to store this to my storage location.

The storage location depends on the type of file being downloaded. In this case “storage/app/public/docs/pdf”.

Can someone please show me the best way to save the thumbnails to the storage location, according to Laravel?


$imagick = new \Imagick($file['temp_path']);
$imagick->resizeImage(200, 200, \Imagick::FILTER_LANCZOS, 1,1);
$file_name = $filename_minus_ext . "-" . time() . "jpg";
14 Dec
1 year ago

cservices left a reply on Complex DB Query

Mine is kinda similar. I decided to go with

Project::where ('cat_id', '=', 1)
            ->whereBetween('start_ts', [$start_month, $end_month])
            ->orWhereBetween('end_ts', [$start_month, $end_month])

Of course I now I realize that I was completely over-thinking this. The other project was even more complex than this. In this case, as long as a recorded entry does not contain a start or end date within the range of the new record, then the new guy can come on in. :D

Thanks for the responses and giving me stuff to think about more clearly.

cservices left a reply on Complex DB Query

The purpose of the query is to find any record of a said category that already exists within the date range the user selected.

If a user puts in the dates of 2/2/18 - 5/15/18 and it records that record successfully, then the months of February, March, April, and May are taken and cannot exist in any other entry for that category.

So if the user tried to place any date in another entry that contained any one of those months, they would be alerted that the months are already taken by another record. There cannot be any overlap.

The start_ts is saved as mm/1/yyyy 00:00:00. The end_ts is saved as mm/last-day-of-month/yyyy 23:59:59.

If anyone knows of another way to do the exact same thing I am certainly open to it. Working with date/time is not my strong point. :)

cservices started a new conversation Complex DB Query

I had to write a complex query for a project long ago. At the time it was written using Drupal. I'm trying to figure out how to write this in Laravel.

I have resorted to writing it using DB::raw(), but would really like to know how to write it using Laravel. It's go so much that I get lost when trying to group parameters.

Can someone show me how the following would be written in Laravel?

Thanks in advance for your time and your help.

''' $raw_sql = "SELECT * FROM projects WHERE ( ( (start_ts <= $start_month) OR (start_ts BETWEEN $start_month AND $end_month) ) AND ( (end_ts BETWEEN $start_month AND $end_month) OR (end_ts > $end_month) ) ) AND (cat_id = 1)";

     $query = DB::select(DB::raw($raw_sql));


20 Oct
1 year ago

cservices left a reply on Adding And Populating A Field To The Users Table

Thank you ftrillo for that. Makes great sense, and I will remember that for later use.

After some searching through the adldap2-laravel docs I found something that prompted me to test and I am glad to say works very well in my case.

The following only applies to adldap2-laravel, which can be found at https://github.com/Adldap2/Adldap2-Laravel/blob/master/docs/auth/fallback.md#developing-locally-without-an-ad-connection

adldap2-laravel can sync your local database with any data you throw at it within the config/adldap_auth.php

At the bottom of the config, under Sync Attributes, I had originally placed

'sync_attributes' => [
        'username' => 'samaccountname',
        'name' => 'cn',

The data coming back from the server had included the email address, so I could add it to the table simply by making the following change.

'sync_attributes' => [
        'username' => 'samaccountname',
        'name' => 'cn',
        'mail' => 'mail',

After this I had to add the “mail” field to by users table. From there I login to my app again, and the field is then populated with the Active Directory email value. Now I have access.

I hope this helps others who use Adldap2-Laravel.

Thanks, Cy

cservices started a new conversation Adding And Populating A Field To The Users Table

I’m a beginner with Laravel, but have been coding PHP for many years. Presently I have a project where I am using “adldap2-laravel” to connect to our Active Directory. The email address is not used for the user login, so I had to make changes per the “adldap2” instructions for using “username”. However, there are times in the app where I need to use some user information that is not part of “Auth::user()”. In this case, the user’s email address.

I need a way to access the user’s email address for use within some of my methods. Otherwise I have to build it within a method, like this. Auth::user()->email = Auth::user()->username . "@mydomain.net"; Or $ useremail = Auth::user()->username . "@mydomain.net";

This is not ideal, as it is not retained in the Auth::user() since it was created in the method.

So I could do this one of two ways. Both in which I need some guidance.

  1. Create a new field in the users table to hold the “useremail” address, which would also be created using code to concatenate username with “@mydomain.net”.

  2. Do the concatenation mention above in some sort of boot or login file.

Ideally, both of these would have the end result as part of the Auth::user() for ease of access any time. BTW, I am using Laravel version 5.4

Suggestions with instructions would be very much appreciated.

Thanks, Cy

06 Apr
2 years ago

cservices started a new conversation Login Via Active Directory And Limited Access

I am using Adldap2 to connect to our Active Directory. I have never done anything like this before, and still getting used to Laravel.

In a previous app I had created a gate: Gate::define('superadmin', function ($user) { return $user->superadmin == 1; });

This worked very well for me.

If I am to understand Adldap2 correctly, and having yet to connect to the Active Directory, when an attempt to login is successful, it will write the user to the 'users' table in the app.

But how do I limit the access to only certain users? Especially since I am not allowed to edit or make changes to the Active Directory.

There are hundreds of people in the Active Directory, but only a handful are to have access to the backend of the app. Can the users be assigned to the 'users' table before they try to use the login via the Active Directory? If not, can I have a field in the table (like “superadmin”) that defaults to null, then manually edit the table and change the value to 1 and have a gate similar as above?

Thanks in advance for your help.

16 Mar
2 years ago

cservices left a reply on Broadcasting Without Redis & Echo

I have been trying to test. I just don't know what is wrong or how to get it to communicate across socket. Here is code info if it can help you help me.

/// CLASS - SomeEvent

15 Mar
2 years ago

cservices started a new conversation Broadcasting Without Redis & Echo

Let me explain what I am trying to do:

I built a dashboard for our Marketing dept. A very simple display of a few of marketing’s happenings. One section is a message board. It is not interactive. It only displays messages entered into the admin, and people can click to read them.

In attempting to learn Broadcasting, I thought it would be nice to update the div containing the messages by prepending new messages to the list, and possibly create an alert of some sort for items updated. All for people who have the dashboard opened if an admin adds/updates a message.

In my looking into socket.io, it appears to me that I don't need the overhead of Redis, and I want to use JQuery, rather than Echo, if at all possible.

The question is, how?

I have played with Events, and I get how they work, but I don't understand anything beyond that when it comes to sending to a socket and so on. I could really use some guidance. The documentation and tutorials I find all use Echo and Redis or Vue and such. But what about if you are not using any of those.

Thanks in advance for your help. Cy

PS: I have zero experience with socket.io. Have been watching some videos that make it look simple, but nothing in the way I want to use it.

14 Mar
2 years ago

cservices left a reply on Broadcasting 1,2,3

Thanks for the response. Much appreciated.

cservices left a reply on Broadcasting 1,2,3

The only problem is that it uses Pusher, and I cannot use a third-party.

I need direction on how to this with Redis, Echo and socket.io. And the only reason I know I need those is because someone in the IRC chat told me so. For all I know that is wrong.

cservices started a new conversation Broadcasting 1,2,3

It’s so frustrating to search for answers on broadcasting, and find that between documentation and other sites that might write things like a tutorial, there is nothing that goes step by step, with an attitude of teaching people as if they just don’t know what is going on.

Broadcasting in Laravel 5.3 looks really cool, and I want to learn it

My company does not want servers communicating outside the network any more than they have to. This means third party is out of the question.

The Laravel 5.3 documentation leaves me with more questions than answers.

Install Redis, Node, Socket.io and Echo. For all I know there is probably four or five other things I need to install. In other words, other than feeling somewhat comfortable with events/listeners, I have no idea how to get this off the ground.

Is there any instruction out there that will show me how to do this step by step? Something that approaches teaching a novice?

I’m not a novice when it comes to PHP, but I am when it comes to Laravel.

Please don’t point me to the docs. I’ve all but seared them to my brain.

Thanks, Cy