tomasosho

tomasosho

Member Since 1 Year Ago

Experience Points
5,720
Total
Experience

4,280 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
1
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 2
5,720 XP
May
19
1 week ago
Activity icon

Replied to I Am Trying To Send Mail Automatically From My Controller

I'm trying to send the mail once the if requirement is met. The mail is dependent on the if requirement which should be automatic @prasadchinwal5

Activity icon

Replied to I Am Trying To Send Mail Automatically From My Controller

So i'm guessing the mail will be sent once the if requirement is met yes? @drewdan

Activity icon

Replied to Call To A Member Function DiffForHumans() On Null (View: C:\xampp\htdocs\project\news\resources\views\front\home.blade.php)

Try this

$hot_news = Post::with('creator')->withCount('comments')->where('hot_news')->where('status')->orderBy('id','DESC')->first();
Activity icon

Replied to Call To A Member Function DiffForHumans() On Null (View: C:\xampp\htdocs\project\news\resources\views\front\home.blade.php)

Try this

@if($hot_news->count() >= 1)

<div class="feature_article_inner">
                        <div class="tag_lg red"><a href="{{ url('/details') }}/{{ $hot_news['slug'] }}">Hot News</a></div>
                        <div class="feature_article_title">
                            <h1><a href="{{ url('/details') }}/{{ $hot_news['slug'] }}" target="_self">{{ $hot_news['title'] }} </a></h1>
                        </div>
                         <!-- feature_article_title -->

 <div class="feature_article_date">
    by: <a href="{{ url('/author') }}/{{ $hot_news['creator']['id'] }}" >{{ $hot_news['creator']['name'] }}</a> ,
       &nbsp;{{$hot_news['created_at']->diffForHumans() }}           </a></div>
                        <!-- feature_article_date -->

                       <div style="font-size: 9.5pt; color: black; "> Views: {{ $hot_news['view_count'] }} </div>

                        <div class="feature_article_content">
                           {{ $hot_news['short_description'] }}
                        </div>
                        <!-- feature_article_content -->

                        <div class="article_social">
                             
                            <span><i class="fas fa-comment"></i><a href="{{ url('/details') }}/{{ $hot_news['slug'] }}">{{ $hot_news['comments_count'] }} Comments </a></span>
                        </div>
                        <!-- article_social -->

                    </div>
@else

<p> No Hot News </p>

@endif
Activity icon

Started a new Conversation I Am Trying To Send Mail Automatically From My Controller

will the code execute?

My Controller

public function mail()
    {
        $alert = Items::whereColumn('number', '<=', 'threshhold')->get();
        $notification = Maintenance::whereBetween('service_date', [today(), today()->addDays(5)])->get();
        
        if ($alert->count() >= 1 or $notification->count() >= 1) {
            foreach ($alert as $a){
                $alerts = $a->title .'for'. $a->title .'has'. $a->number .'left, which is below the Threshold of'. $a->threshhold .'Please restock quickly';
            }
            foreach ($notification as $n){
                $notifications = $n->machine_title. $n->description .'is due for servicing on'. $n->service_date. 'Thank You!';
            }

            Mail::to('email address')->send(new SendMailable($alerts, $notifications));
        }
    }

SendMailable

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class SendMailable extends Mailable
{
    use Queueable, SerializesModels;
    public $name;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($name)
    {
        $this->notifications = $notifications;
        $this->notifications = $notifications;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('/');
    }
}
May
18
1 week ago
Activity icon

Replied to How Cant I Embed An Html Video In Css Background

I'm not trying to adjust backgrounds. But thanks

Activity icon

Started a new Conversation How Cant I Embed An Html Video In Css Background

example (background-image:/link) i want the link to be a video instead of a picture.

I don't want to use ``` I am trying to make my video undownloadable to an extent, at least not with a simple right click

Activity icon

Started a new Conversation How Do I Encrypt A Link?

How do I encrypt a link so after every click the link changes?

May
15
2 weeks ago
May
14
2 weeks ago
Activity icon

Replied to I Want To Get Properties Of A Column From A Table With Same Id From Another Table

$products is meant to be an object not an array

Activity icon

Started a new Conversation I Want To Get Properties Of A Column From A Table With Same Id From Another Table

This is meant to give me a category id that's same as a product. but i'm getting an empty array from my dd

$cat = Category::where('id', $products->id)->get();
        dd($cat);
May
10
2 weeks ago
Activity icon

Replied to Sweetalert Is Not Working.

Show the header of your view file

Activity icon

Replied to Error 404 - Page Not Found In Dropdown List Filter

/admin/leaves first your urls

Activity icon

Replied to Php Artisan View:clear Not Working

Try ctrl f5 or cmd f5 after clearing

Activity icon

Replied to Can Someone Help Me Out

I've done that @guybrush_threepwood and @kkhicher1 were really helpful. I just need to correct my file path

This is telling me filepath does not exist

file_put_contents('storage/public/avatars',file_get_contents($imageName, $data));
Activity icon

Replied to Can Someone Help Me Out

This is telling me filepath does not exist

file_put_contents('storage/public/avatars',file_get_contents($imageName, $data));
Activity icon

Replied to Can Someone Help Me Out

Last one

I want to save the pictures in a folder called avatars

My present code, saves it directly to the public folder

if(isset($_POST["avatar"]))
        {
        $data = $_POST["avatar"];

        $image_array_1 = explode(";", $data);

        $image_array_2 = explode(",", $image_array_1[1]);

        $data = base64_decode($image_array_2[1]);

        $imageName = time() . '.png';

        file_put_contents($imageName, $data);

        $user = Auth::user();

        $user->avatar = $imageName;
        $user->save();

        return redirect("/profile/{$user->id}/{$user->username}")
            ->with('success','You have successfully upload image.');
        }
May
09
3 weeks ago
Activity icon

Replied to Can Someone Help Me Out

I think i'd have to convert from URI to save as image. Can you help?

Activity icon

Replied to Search For Laravel Comments Plugin

I don't know if there's a plugin like that. My advice would be that you can start by adding comments to posts, attaching user Id relationships to comments and posts. Adding roles in which you'd have the admin role. And the restricting privileges from roles created.

Activity icon

Replied to Can Someone Help Me Out

Nothing is being saved at all

Activity icon

Replied to Can Someone Help Me Out

Thanks, it's working but the cropped image is not saving or updating. or it's not submitting the image in the controller

Activity icon

Replied to Can Someone Help Me Out

Got this error message

{message: "The given data was invalid.",…}
errors: {upload_image: ["The upload image field is required."]}
upload_image: ["The upload image field is required."]
0: "The upload image field is required."
message: "The given data was invalid."

when i took out the validation, i got an error 500

Activity icon

Replied to Can Someone Help Me Out

I changed the input name to avatar and i'm still getting same error

Activity icon

Replied to Can Someone Help Me Out

My Controller

$request->validate([
            'avatar' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        ]);

        $user = Auth::user();

        $avatarName = $user->id.'_avatar'.time().'.'.request()->avatar->getClientOriginalExtension();

        $request->avatar->storeAs('avatars',$avatarName);

        $user->avatar = $avatarName;
        $user->save();

        return redirect("/profile/{$user->id}/{$user->username}")
            ->with('success','You have successfully upload image.');

When i filtered the error message to XHR i got {message: "The given data was invalid.", errors: {avatar: ["The avatar field is required."]}} errors: {avatar: ["The avatar field is required."]} avatar: ["The avatar field is required."] message: "The given data was invalid."

Activity icon

Replied to Can Someone Help Me Out

I'm getting this now

POST http://127.0.0.1:8000/profile 422 (Unprocessable Entity)
Activity icon

Replied to Can Someone Help Me Out

Yes CRSF token is set

Route::post('/profile', '[email protected]_avatar')->middleware('auth');
Activity icon

Replied to Can Someone Help Me Out

i'm getting

jquery.min.js:4 POST http://127.0.0.1:8000/profile 405 (Method Not Allowed)
Activity icon

Replied to Can Someone Help Me Out

In my console when the Upload button is not working i get 405 Method Not Allowed

Activity icon

Started a new Conversation Can Someone Help Me Out

I am trying to upload, crop then save my image to my database. The problem i have is the upload button is not wotking. and when i get it to work, it doesn't send data to the controller.

<html>  
    <head>  
        <title>Test Test</title>  
  
    <script src="{{asset('js/jquery.min.js')}}"></script>  
		<script src="{{asset('js/bootstrap.min.js')}}"></script>
		<script src="{{asset('js/croppie.js')}}"></script>
		<link rel="stylesheet" href="{{asset('css/bootstrap.min.css')}}" />
		<link rel="stylesheet" href="{{asset('css/croppie.css')}}" />
    </head>  
    <body>  
        <div class="container">
          <br />
      <h3 align="center">Image Crop & Upload using JQuery with PHP Ajax</h3>
      <br />
      <br />
   <div class="panel panel-default">
      <div class="panel-heading">Select Profile Image</div>
      <div class="panel-body" align="center">
       <input type="file" name="upload_image" id="upload_image" accept="image/*" />
       <br />
       <div id="uploaded_image"></div>
      </div>
     </div>
    </div>
    </body>  
</html>

<div id="uploadimageModal" class="modal" role="dialog">
 <div class="modal-dialog">
  <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Upload & Crop Image</h4>
        </div>
        <div class="modal-body">
          <div class="row">
       <div class="col-md-8 text-center">
        <div id="image_demo" style="width:350px; margin-top:30px"></div>
       </div>
       <div class="col-md-4" style="padding-top:30px;">
        <br />
        <br />
        <br/>
        <button class="btn btn-success crop_image">Crop & Upload Image</button>
     </div>
    </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
     </div>
    </div>
</div>

<script>  
$(document).ready(function(){

 $image_crop = $('#image_demo').croppie({
    enableExif: true,
    viewport: {
      width:200,
      height:200,
      type:'square' //circle
    },
    boundary:{
      width:300,
      height:300
    }
  });

  $('#upload_image').on('change', function(){
    var reader = new FileReader();
    reader.onload = function (event) {
      $image_crop.croppie('bind', {
        url: event.target.result
      }).then(function(){
        console.log('jQuery bind complete');
      });
    }
    reader.readAsDataURL(this.files[0]);
    $('#uploadimageModal').modal('show');
  });

  $('.crop_image').click(function(event){
    $image_crop.croppie('result', {
      type: 'canvas',
      size: 'viewport'
    }).then(function(response){
      $.ajax({
        url:"/profile",
        type: "POST",
        data:{"image": response},
        success:function(data)
        {
          $('#uploadimageModal').modal('hide');
          $('#uploaded_image').html(data);
        }
      });
    })
  });

});  
</script>
Activity icon

Started a new Conversation Upload Button To Submit Not Working After Cropping

<script type="text/javascript">

        $.ajaxSetup({

        headers: {

            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

        }

        });

        var resize = $('#upload-demo').croppie({

            enableExif: true,

            enableOrientation: true,    

            viewport: { 

                width: 200,

                height: 200,

                type: 'circle'

            },

            boundary: {

                width: 300,

                height: 300

            }

        });

        $('#image').on('change', function () { 

        var reader = new FileReader();

            reader.onload = function (e) {

            resize.croppie('bind',{

                url: e.target.result

            }).then(function(){

                console.log('jQuery bind complete');

            });

            }

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

        });

        $('.upload-image').on('click', function (ev) {

        resize.croppie('result', {

            type: 'canvas',

            size: 'viewport'

        }).then(function (img) {

            $.ajax({

            url: "{{route('upload.image')}}",

            type: "POST",

            data: {"image":img},

            success: function (data) {

                html = '<img src="' + img + '" />';

                $("#preview-crop-image").html(html);

            }

            });

        });

        });

    </script>

<div class="col-md-4 text-center">

            <div id="upload-demo"></div>

        </div>

        <div class="col-md-4" style="padding:5%;">

            <strong>Select image to crop:</strong>

            <input type="file" id="image">

            <button class="btn btn-primary btn-block upload-image" type="submit" style="margin-top:2%">Upload Image</button>

        </div>

        <div class="col-md-4">

            <div id="preview-crop-image" style="background:#9d9d9d;width:300px;padding:50px 50px;height:300px;"></div>

        </div>
Activity icon

Started a new Conversation How To Crop Picture Before Upload (Upload Button Not Working)

<div class="col-md-4 text-center">

            <div id="upload-demo"></div>

        </div>

        <div class="col-md-4" style="padding:5%;">

            <strong>Select image to crop:</strong>

            <input type="file" id="image">

            <button class="btn btn-primary btn-block upload-image" id="upload-image" style="margin-top:2%">Upload Image</button>

        </div>

        <div class="col-md-4">

            <div id="preview-crop-image" style="background:#9d9d9d;width:300px;padding:50px 50px;height:300px;"></div>

        </div>



<script type="text/javascript">

        $.ajaxSetup({

        headers: {

            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

        }

        });

        var resize = $('#upload-demo').croppie({

            enableExif: true,

            enableOrientation: true,    

            viewport: { 

                width: 200,

                height: 200,

                type: 'circle'

            },

            boundary: {

                width: 300,

                height: 300

            }

        });

        $('#image').on('change', function () { 

        var reader = new FileReader();

            reader.onload = function (e) {

            resize.croppie('bind',{

                url: e.target.result

            }).then(function(){

                console.log('jQuery bind complete');

            });

            }

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

        });

        $('.upload-image').on('click', function (ev) {

        resize.croppie('result', {

            type: 'canvas',

            size: 'viewport'

        }).then(function (img) {

            $.ajax({

            url: "{{route('upload.image')}}",

            type: "POST",

            data: {"image":img},

            success: function (data) {

                html = '<img src="' + img + '" />';

                $("#preview-crop-image").html(html);

            }

            });

        });

        });

    </script>

My controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ImageController extends Controller
{
    public function index()

    {

      return view('imageUpload');

    }

    public function uploadImage(Request $request){

        $request->validate([
            'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        ]);

        $user = Auth::user();

        $imageName = $user->id.'_image'.time().'.'.request()->image->getClientOriginalExtension();

        $request->image->storeAs('images',$imageName);

        $user->image = $imageName;
        $user->save();

        return redirect("/profile/{$user->id}/{$user->username}")
            ->with('success','You have successfully upload image.');

    }
}
Apr
30
1 month ago
Activity icon

Replied to I Want To Foreach Notification 5days Before The Service Date

i got [] array, i had to run migration again. I think there was some type of error.

Activity icon

Started a new Conversation I Want To Foreach Notification 5days Before The Service Date

I want to foreach notification in my view 5days before the service_date`` service_dateis set by the user and date serviced is also set by the user asdate```. How do i go about it? The code only displays notification when the service_date = today's date

$date = date("Y-m-d");
$notification = Maintenance::where('service_date', '=', $date)->get();
Activity icon

Started a new Conversation SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column '1' In 'where Clause' (SQL: Select * From `items` Where `1` Is Null)

i want to get results when number is less than equal to threshhold

$salert = Items::where('number' <= 'threshhold')->get();
Activity icon

Replied to Error Call To A Member Function AddDays() On String

what will you recommend i do?

Activity icon

Replied to Error Call To A Member Function AddDays() On String

I'm trying to set it to display 5 days to the service day... is it correct?

$notification = Maintenance::where('service_date', '>=', 'date->addDays(5)')->get();
OR
$notification = Maintenance::where('service_date->subDays(5)', '<=', 'service_date')->get();
Activity icon

Started a new Conversation Error Call To A Member Function AddDays() On String

I am trying to add 5 days to the date service_date I am getting Error Call to a member function addDays() on string

$notification = Maintenance::where(now(), '<=', 'service_date'->addDays(5))->get();
Activity icon

Started a new Conversation If Either $value1 And $value2 Is Not Null

How do i write the statement?

If either $value1 and $value2 is not null

if ($request->input('input') or $request->input('output') = null)
Apr
28
1 month ago
Activity icon

Started a new Conversation I Want To Display Notification 5 Days To The Date Saved

$parts = explode('-', $$maintain->service_date);
        if ($datePlusFive = date(
            'Y-m-d', 
            mktime(0, 0, 0, $parts[1], $parts[2] + 5, $parts[0])
            //              ^ Month    ^ Day + 5      ^ Year
        ) ) {
            
            $notification = 'Display this';
        } 

What can i do?

Apr
15
1 month ago
Activity icon

Started a new Conversation How Do I Get The Role Of A Current User?

Auth()->user()->select('roles')->get();
Activity icon

Replied to I Want To Display Only Users That Have A Certain Role

Thank alot. I just learnt something new!

Activity icon

Started a new Conversation I Want To Display Only Users That Have A Certain Role

I have linked my user table and role table now i have role_user table with the structure

CREATE TABLE role_user (
    id         INTEGER  NOT NULL
                        PRIMARY KEY AUTOINCREMENT,
    role_id    INTEGER  NOT NULL,
    user_id    INTEGER  NOT NULL,
    created_at DATETIME,
    updated_at DATETIME
);

I want to display only users with role_id of 2

E.g.

$users = User::where('role_id', 2)->paginate(4);
or
$displayusers = DB::table('users')->select('role_user')->where('role_id', '4')->paginate(4);

Both are giving me empty arrays.

What can i do?

Activity icon

Replied to I Want To Display Only Users That Have A Certain Role

$displayusers = DB::table('users')->select('role_user')->where('role_id', '4')->paginate(4);

This one is also blank

Activity icon

Replied to I Want To Display Only Users That Have A Certain Role

This is working,

$displayusers = DB::table('role_user')->where('role_id', '4')->paginate(4);

but i'm not getting data from my user table