Ap3twe

Ap3twe

Member Since 3 Months Ago

Experience Points 6,280
Experience Level 2

3,720 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 44
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • 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.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    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.

12 Jul
3 days ago

Ap3twe left a reply on Multiple Inputs Field Styling

I will create jsfiddle file and show it so you can get it

24 Jun
3 weeks ago

Ap3twe started a new conversation FIrst Laravel Project Completed

Thanks to all the team and helpful guys on this platform. I completed my first laravel project. Special thanks to regulars like @Cronix, Tray2, Jlrdw, Snapey, and Bobbybouwmann. I will keep learning that is the keyword!

23 Jun
3 weeks ago

Ap3twe left a reply on Multiple Inputs Field Styling

@TRAY2 - Let me clarify. Css input fields is tricky to to style. I found this code with styling and drag and drop. It works perfectly. I just want to use it many times in the page. In the current state when tge script affects all the input fields when I select a file. I can solve it by using classes for each input field and having the Js script dedicated to each. What I want is how do I write only 1 Js script to control each input. Field independently? Thank you I hope you get it now. Example : input 1, input 2, input 3. They are not related but use one script to manipulete the styling.

21 Jun
3 weeks ago

Ap3twe left a reply on Multiple Inputs Field Styling

I was thinking of a better way of not using the script many times. That means I have to copy the script 9ine times

Ap3twe left a reply on Multiple Inputs Field Styling

@TRAY2 - I am styling file input fields.

Ap3twe started a new conversation Multiple Inputs Field Styling

I would like to use this input file code in my project. My reason is styling the input field. The downside is I have 9 input fields in my HTML. The reason I did not use one input [multiple] is that they are not related so I want the user to upload the files each one by one depending on the condition I will set. I found this code. When I upload a file It gets loaded to all the rest of the inputs. Is there a way I don't have to duplicate the many times? I want to use only one script to control all the input fields. the question is it is possible or I have to copy each script separately?

<div class="file-upload">
  <button class="file-upload-btn" type="button" onclick="$('.file-upload-input').trigger( 'click' )">Add Image</button>

  <div class="image-upload-wrap">
    <input class="file-upload-input" type='file' onchange="readURL(this);" accept="image/*" />
    <div class="drag-text">
      <h3>Drag and drop a file or select add Image</h3>
    </div>
  </div>
  <div class="file-upload-content">
    <img class="file-upload-image" src="#" alt="your image" />
    <div class="image-title-wrap">
      <button type="button" onclick="removeUpload()" class="remove-image">Remove <span class="image-title">Uploaded Image</span></button>
    </div>
  </div>
</div>


  .file-upload {
    background-color: #ffffff;
    width: 300px;
    min-width: 15%;
    margin: 0 auto;
    padding: 20px;
  }

  .file-upload-btn {
    width: 100%;
    margin: 0;
    color: #fff;
    background: #085aad;
    border: none;
    padding: 10px;
    border-radius: 4px;
    border-bottom: 4px solid #085aad;
    transition: all .2s ease;
    outline: none;
    text-transform: uppercase;
    font-weight: 700;
  }

  .file-upload-btn:hover {
    background: #F4754E;
    color: #ffffff;
    transition: all .2s ease;
    cursor: pointer;
  }

  .file-upload-btn:active {
    border: 0;
    transition: all .2s ease;
  }

  .file-upload-content {
    display: none;
    text-align: center;
  }

  .file-upload-input {
    position: absolute;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    outline: none;
    opacity: 0;
    cursor: pointer;
  }

  .image-upload-wrap {
    margin-top: 20px;
    border: 4px dashed #085aad;
    position: relative;
  }

  .image-dropping,
  .image-upload-wrap:hover {
    background-color: #999;
    border: 4px dashed #ffffff;
  }

  .image-title-wrap {
    padding: 0 15px 15px 15px;
    color: #222;
  }

  .drag-text {
    text-align: center;
  }

  .drag-text h3 {
    font-weight: 100;
    text-transform: uppercase;
    color: #085aad;
    padding: 60px 0;
  }

  .drag-text h3:hover {
     color: #fff;
  }

  .file-upload-image {
    max-height: 200px;
    max-width: 200px;
    margin: auto;
    padding: 20px;
  }

  .remove-image {
    width: 200px;
    margin: 0;
    color: #fff;
    background: #F4754E;
    border: none;
    padding: 10px;
    border-radius: 4px;
    border-bottom: 4px solid #b02818;
    transition: all .2s ease;
    outline: none;
    text-transform: uppercase;
    font-weight: 700;
  }

  .remove-image:hover {
    background: #c13b2a;
    color: #ffffff;
    transition: all .2s ease;
    cursor: pointer;
  }

  .remove-image:active {
    border: 0;
    transition: all .2s ease;
  }
function readURL(input) {
    if (input.files && input.files[0]) {

      var reader = new FileReader();

      reader.onload = function(e) {
        $('.image-upload-wrap').hide();

        $('.file-upload-image').attr('src', e.target.result);
        $('.file-upload-content').show();

        $('.image-title').html(input.files[0].name);
      };

      reader.readAsDataURL(input.files[0]);

    } else {
      removeUpload();
    }
  }

  function removeUpload() {
    $('.file-upload-input').replaceWith($('.file-upload-input').clone());
    $('.file-upload-content').hide();
    $('.image-upload-wrap').show();
  }
  $('.image-upload-wrap').bind('dragover', function () {
          $('.image-upload-wrap').addClass('image-dropping');
      });
      $('.image-upload-wrap').bind('dragleave', function () {
          $('.image-upload-wrap').removeClass('image-dropping');
  });
22 May
1 month ago

Ap3twe left a reply on How Do I Get The Updated_at

Any suggestion on @cronix method?

21 May
1 month ago

Ap3twe left a reply on How Do I Get The Updated_at

@TRAY2 - Your method works perfectly. The only thing is I get empty value in the DB.

Ap3twe left a reply on How Do I Get The Updated_at

@CRONIX - I got an empty value in the db. This is how I tried it

$published = $project->publish = "Published";

$project->fill(['publish' => $published]);

Ap3twe left a reply on Getting The Value Of Date (Y:M:D)?

@CRONIX - Thank you. It works

Ap3twe left a reply on How Do I Get The Updated_at

@TISUCHI - Let me clarify my question. In my project, A user creates a project and I show the value from the database "New". I passed a default value '' New'' . I wanna get the second value from the boolean if the user updates the project. That value is ''Published''.

Ap3twe left a reply on Getting The Value Of Date (Y:M:D)?

@TISUCHI - I wasn't sure. Did you put it in the User model or controller?

Ap3twe left a reply on How Do I Get The Updated_at

@TISUCHI - I tried this condition. I think the updated_at updates when I create a project.

@if ($project->updated_at)
       <td> <a href="/smiledesign/{{$project->id}}/userproject">Published</a></td>
        @else
       <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->publish}}</a></td>
        @endif

Ap3twe left a reply on Getting The Value Of Date (Y:M:D)?

Did not work. A question though is the getFromDateAttribute a global method from laravel? I copied that function on stackoverflow.

Ap3twe started a new conversation How Do I Get The Updated_at

I want to get the value of the boolean when a project is updated. The problem is in MySQL database, the updated_at gets updated when a project is created. How do I get the value published when a project is updated?

This is the table schema

In the view, I get the default value

<td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->publish}}</a></td>

I wanna get the boolean Published when the project gets updated

Ap3twe started a new conversation Getting The Value Of Date (Y:M:D)?

I wanna get only Y:M:D. In laravel the created_at returns hour, minutes and second. I tried to use public function getFromDateAttribute($value) { return \Carbon\Carbon::parse($value)->format('d-m-Y'); } in the user model. It still returns 2019-05-15 20:38:42

17 May
1 month ago

Ap3twe left a reply on What Is The Best Approach For Data Visibility Restriction? (guest,members,subscribers)

@jlrdw How can I contact you? I wanna discuss some little gig with you

Ap3twe left a reply on Laracast Possibility Of Adding Friend

@JLRDW - I get you. What about in case we wanna hire or collaborate with someone. How can we shoot the person a message?

16 May
1 month ago

Ap3twe started a new conversation Laracast Possibility Of Adding Friend

It will be useful if we can add users as friends on laracast. What do yall think?

Ap3twe left a reply on Making A Route Public For Anyone To View

I fixed it.. I will test it for days and confirm it guys.abort_unless(auth()->user()->isAdmin || $project->user_id == auth()->id(), 403); Thank you all. I appriciate your help

Ap3twe left a reply on Making A Route Public For Anyone To View

How do I give access to the admin too? How do I write the condition by adding is_admin?

Ap3twe left a reply on Making A Route Public For Anyone To View

@SNAPEY - Sorry it is working when I changed abort_if(! $project->user_id == auth()->id(), 403); to ``abort_if( $project->user_id !== auth()->id(), 403);```

Ap3twe left a reply on Making A Route Public For Anyone To View

@SNAPEY - I tried your solution. The route does not abort. I dump it and it returns null

$bbd  =  abort_if(! $project->user_id == auth()->id(), 403);
        dd($bbd);

Ap3twe left a reply on Making A Route Public For Anyone To View

@CRONIX - I posted all the controllers

Ap3twe left a reply on Making A Route Public For Anyone To View

This is my middleware

<?php

namespace App\Http\Middleware;
use App\Project;

use Closure;

class FinalForm
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */


    public function handle($request, Closure $next)
    {

        // $project = Project::where('user_id', auth()->id())->get();
        $project = Project::find('id');
        $user_id = $project->user_id;
        if($user_id != auth()->user()->id){
            return redirect('/')->with('error', 'You are not able to see this page');

        }


        return $next($request);
    }
}

Controller

    // Published page
    public function published(project $project){
        $project = Project::where('user_id', auth()->id())->find(session('created_id'));
        return view ('/smiledesign.published', compact('project'));

    }

    public function doctorfinalform(Project $project, request $request){

        // $this->authorize('doctorfinalform', $project);

        return view('smiledesign.doctorfinalform', compact('project'));
    }

Route

Route::get('/smiledesign/{project}/doctorfinalform', '[email protected]')->middleware('finalForm');

Ap3twe left a reply on Making A Route Public For Anyone To View

@CRONIX - I want it to be dynamic. Assigning 4 is hard coded. I want to block other users from seeing the form.

Ap3twe left a reply on Making A Route Public For Anyone To View

@JLRDW - I appreciate. I am learning

Ap3twe left a reply on Making A Route Public For Anyone To View

@CRONIX - Replacing the string with integer throws an error Use of undefined constant id - assumed 'id' (this will throw an Error in a future version of PHP)

Ap3twe left a reply on Making A Route Public For Anyone To View

I get error Trying to get property 'user_id' of non-object

    public function handle($request, Closure $next)
    {
 
        $project = Project::find('id');
        $user_id = $project->user_id;
        if($user_id != auth()->user()->id){
            return redirect('/')->with('error', 'You are not able to see this page');
 
        }
 
 
        return $next($request);
    }
}

Ap3twe left a reply on Making A Route Public For Anyone To View

@SNAPEY - All doctors are protected. The problem I have is I am taking the form submitted by the doctor and updating it with new contents and sending it back to him. That makes it that the route is coming from protected admin and then releasing access back to the doctor. If I release access as public routes, anybody can see each other project. I am gonna protect it with the suggestion from @jlrdw

15 May
2 months ago

Ap3twe left a reply on Making A Route Public For Anyone To View

@JLRDW - I created a middleware. Yet all users can see each other project. What condition do I have to provide?

Route::get('/smiledesign/{project}/doctorfinalform', '[email protected]')->middleware('finalForm');

<?php

namespace App\Http\Middleware;

use Closure;

class FinalForm
{
    
    public function handle($request, Closure $next)
    {

        if(auth()->user()->id){
           
        }
        return $next($request);
    }
}

Ap3twe left a reply on Making A Route Public For Anyone To View

@SNAPEY - @snapey That is what I was thinking. I have to make a decision to leave that out. Security is important. I will limit it to the doctor

Ap3twe left a reply on Making A Route Public For Anyone To View

@ I will give it a try

Ap3twe left a reply on Making A Route Public For Anyone To View

@I need the authentication in the ```__contruct()`` or else all the pages will be public. I want only the doctorfinalform to be public

Ap3twe started a new conversation Making A Route Public For Anyone To View

I want to allow a route to be public for anyone who has the URL to view. It is coming from protected routes from the admin. The admin creates the pages and the final page we would send it to a doctor who will also send it to the patients. How can I create a public URL from Route::get('/smiledesign/{project}/doctorfinalform', '[email protected]');

The view is like this http://blog.test/smiledesign/4/doctorfinalform

Here are my routes

  Auth::routes();

// Users Routes
Route::get('/home', '[email protected]')->name('home');
Route::get('/smiledesign/create', '[email protected]');
Route::post('/store', '[email protected]');
Route::get('/smiledesign/{project}/show', '[email protected]');
Route::get('/smiledesign/success', '[email protected]');
Route::get('/smiledesign/cases', '[email protected]');

// Doctor final form
Route::get('/smiledesign/{project}/doctorfinalform', '[email protected]');

// Admin redirect to dashboard
Route::get('/admin', '[email protected]')->middleware('admin');

// Admin Routes
Route::middleware('forStaff')->group(function () {
Route::get('/smiledesign/adminforms', '[email protected]');
Route::get('/smiledesign/{project}/records', '[email protected]');
Route::patch('/smiledesign/{project}', '[email protected]');
Route::get('/smiledesign/{project}/edit', '[email protected]');
Route::delete('/smiledesign/{project}', '[email protected]');
Route::get('/smiledesign/{project}/userproject', '[email protected]');
Route::get('/smiledesign/published', '[email protected]');
});

 // Published page
    public function published(project $project){
        $project = Project::where('user_id', auth()->id())->find(session('created_id'));
        return view ('/smiledesign.published', compact('project'));

    }

    public function doctorfinalform(Project $project, request $request){

        return view('smiledesign.doctorfinalform', compact('project'));
    }
14 May
2 months ago

Ap3twe started a new conversation Authentication External API As A Middleware

Hey, I want to authenticate users with external API before allowing the request to go through the laravel auth. Users are stored in our CPM system and we want to limit other users from logging into our app. The API is written in WSDL. An example was provided with soap. How do I implement it laravel?

function _getCustomerInfo($user,$pass){
        /* Initialize webservice with your WSDL */
        $client = new SoapClient("https://bbcpmws.example.com:099/Token.asmx?WSDL");
        
        $params = array(
            'APIUserID' => '{id}',
            'APIPassword' => '{password}',
            'webUsername' => $user,
            'webPassword' => $pass,
        );
        try {
            $responsetest = $client->getCustomerInfo($params);
            
        } catch(SoapFault $fault) {
            return False;
        }
        
         $_SESSION['customer_info'] = $responsetest;
        
        return True;
    }

Ap3twe started a new conversation DataTables Ordering & Serching

I am using datatables in Laravel. The values are inserted with dynamic blade syntax. When I click ordering, it does not sort. Searching returns no match even though I provide the correct values. How do I solve this? NB: Looking in the chrome console, I see the table body changes state.

       //Table cases javascritpt
              $(document).ready( function () {
              $('#table_id').DataTable();

               } );
               $.extend( $.fn.dataTable.defaults, {

                 ordering: true,
                 searching:true,
                 select: true,
                 "order": [[ 0, 'desc' ], [ 1, 'desc' ], [2, 'desc'], [3, 'desc']]
              } );
 <table class="table table-striped table-bordered" id="table_id">
            <thead>
                    <tr>
                            <th>Case Number</th>
                            <th>Case Form</th>
                            <th>Patient Name</th>
                            <th>Date Created</th>
                            <th>Status</th>
                    </tr>
            </thead>
            @foreach ($project as $project)
            <tbody>
              
             <tr>
                
                 <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->case_number}}</a></td>
                
                 @if ($project->services0)
                 <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->services0}}</a></td> 
                 @elseif ($project->services1)
                 <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->services1}}</a></td> 
                 @elseif ($project->services2)
                 {{-- <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->services2 . '  '  . $project->mockup0}}</a></td>  --}}
                 <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->services2 . '  '  . $project->mockup0 . ' ' . $project->mockup1}}</a></td> 

                 @endif
                 <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->first_name . ' ' . $project->last_name}}</a></td>
                 <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->created_at}}</a></td>
                 <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->concerns}}</a></td> 
             </tr>

         </tbody>
         @endforeach

     </table>
01 May
2 months ago

Ap3twe left a reply on How Do You Connect To The Mysql Database Using Valet?

@TYKUS - Oh I see. So I have to have myqsl database running. Xampp can do the job. Thanks

Ap3twe started a new conversation How Do You Connect To The Mysql Database Using Valet?

In the laravel documentation, it says " you can then connect to the database at 127.0.0.1 using the root username and an empty string for the password" 127.0.0.1 in the browser is not working. Do I have to change the host file as we do in windows?

Ap3twe left a reply on Laravel Valet Database Configuration - Migrate

Dude that is homestead database posted.

26 Apr
2 months ago

Ap3twe left a reply on Image Intervention Changing File Upload To Multiple Files

I am getting an error Invalid argument supplied for foreach(). On the datatype in the DB, I am using string $table->string('lab_quote[]')->nullable();

Ap3twe left a reply on Image Intervention Changing File Upload To Multiple Files

@SERGIU17 - So the variable $file. Where is it coming from?

Ap3twe started a new conversation Image Intervention Changing File Upload To Multiple Files

I am using Intervention to upload files. Now I want to have the files upload as an array of files.(multiple) How do I go about it? I tried lab_quote[] but is not working. Or is it best practice to have each file as a separate column in the db?

 if ($request->hasFile('lab_quote')){
        // get file Name
        $quotenameWithExt = $request->file('lab_quote')->getClientOriginalName();
        //The image path and name
        $quotefilename = pathinfo($quotenameWithExt, PATHINFO_FILENAME);
        // get the exxtension
        $quoteextension = $request->file('lab_quote')->getClientOriginalExtension();
        // Name append a time stamp
        $labquotefileNameToStore = $quotefilename.'_' .time(). '.' . $quoteextension;
        // Move the file to the folder
        // $stlpath = $request->file('stl_image')->storeAs('public/uploads', $stlfileNameToStore);
        $qtlpath = $request->file('lab_quote')->storeAs('public/uploads/thumbnails', $labquotefileNameToStore);
        // Resize
        $quote = public_path('storage/uploads/thumbnails'. $labquotefileNameToStore);
        $qto = Image::make($_FILES['lab_quote']['tmp_name']);
        $qto->resize('443','313');
        $qto->save($quote);
        
    }
$project->fill(['lab_quote' => $labquotefileNameToStore]);
project->save();
23 Apr
2 months ago

Ap3twe left a reply on Updating Database Using UpdateOrCreate Method

@SNAPEY - I tried the first example before, It gave me an error. It throws undefined variable. I will utilize the second example. I think is clean. My problem was trying to use the create method but was giving me user constraint error. So I was reading the docs to find alternative, I thought the updateOrCreate will insert the values if it doesn't have a record in the fields. What is the use of the updateOrCreate Method?

Ap3twe left a reply on About Frameworks

@SABEELK - It is a waste of time. I think if the project is just a content website nothing more, go with WordPress. Work for money as time is the essence. I won't use laravel to build a simple website. I am new to Laravel after years of Front-End WordPress, React and Node. I used to hate PHP but Laravel has got me motivated.