Cinek

Experience

8,030

14 Best Reply Awards

  • Member Since 6 Months Ago
  • 1 Lesson Completed
  • 0 Favorites

11th February, 2018

Cinek left a reply on Laravel Carbon Date Difference Between Two Dates • 1 week ago

What type is your "starttime" field in your database? I see, that the Eloquent didn't parse starttime to Carbon. You have 2 options:

  1. Parse starttime to Carbon directly in function
$cleanCollection = Clean::get(['starttime','created_at']);
    foreach($cleanCollection as $cleanObj){
        $startTime = Carbon::parse($cleanObj->starttime);
        $diff = $cleanObj->created_at->diffInHours($startTime);
    }
  1. Add to your Clean model a mutator (https://laravel.com/docs/5.5/eloquent-mutators#accessors-and-mutators), that will be parse "starttime" to carbon automatically and first code will work:
public function getStarttimeAttribute($date)
    {
        return Carbon::parse($date);
    }

Notice: if you pass to parse method null, the Carbon will return actual time

Cinek left a reply on /app\models Directory Does Not Exist. • 1 week ago

In your case better choice is to use php constant: $models = \File::allFiles(app_path() . DIRECTORY_SEPARATOR.'models');

Cinek left a reply on Laravel Carbon Date Difference Between Two Dates • 1 week ago

Note, that the $cleanStart variable is an array of dates so you should fetch only one row or calculate date diff for each row.

Example:

$cleanCollection = Clean::get(['starttime','created_at']);
    foreach($cleanCollection as $cleanObj){
        $diff = $cleanObj->created_at->diffInHours($cleanObj->starttime);
    }

You don't need to parse created_at and starttime to Carbon, an Eloquent should do it automatically.

10th February, 2018

Cinek left a reply on /app\models Directory Does Not Exist. • 1 week ago

I think that u have your models directory in lower case. You should to change it to upper case and it will running properly on unix an windows.

21st January, 2018

Cinek left a reply on Set Default Value For User • 4 weeks ago

You can specify default value in the database migration:

$table->integer('points')->default(0)

or set default value while inserting to DB:

return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
'points'=>0
        ]);

10th January, 2018

Cinek left a reply on Image Doesn't Appear How Can I Update It • 1 month ago

Did you used "'files'=>'true'" in your form?

5th January, 2018

Cinek left a reply on Fake JSON Data For Testing. • 1 month ago

Simple example to generate random date from 1970-01-01 to now:

$now = time();
$date = Carbon::createFromTimestamp($now - rand(1,$now))->toDateString();

Cinek left a reply on Update Query With Two Conditions • 1 month ago

DB::table('attendence') 
->where('name',$name)
->whereNull('type')
->update([ 'checkedout' => $this->data->checkedout, 'type'=> $this->data->type, ]);

28th December, 2017

24th December, 2017

Cinek started a new conversation Experience Issue. • 1 month ago

If i like my own answer in any thread, my exp doesn't grow up. It's normal i think. But if i withdraw my vote, exp decreases by 50. I can reset my exp by clicking many times on "like" button.

Cinek left a reply on Relationship Method Working But Not Property • 1 month ago

Show code of your model class

21st December, 2017

Cinek left a reply on Controller Problem After Uploading To Server • 1 month ago

Maybe it's problem with your controller class name? Windows is case-insensitive, but UNIX systems are case-sensitive.

Cinek left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Array Given • 1 month ago

Replace

        {!!Form::text('name',['placeholder'=>'Enter Category Name','class'=>'form-control'])!!}

to

        {!!Form::text('name',null,['placeholder'=>'Enter Category Name','class'=>'form-control'])!!}

Second parameter can't be an array. It's value of input.

Cinek left a reply on RAW Query Throws Incomplete Data • 1 month ago

Can you paste sample code?

18th December, 2017

Cinek left a reply on How To Implement Laravel Fake ID • 2 months ago

I don't know this library but the error indicates the lack of a library PHP GMP. It's not standard php library so you have to install it manually. http://php.net/manual/en/book.gmp.php

13th December, 2017

Cinek left a reply on Eloquent Many To Many • 2 months ago

$ids = [1,2];
    $users = \App\User::whereHas('roles', function ($query) use ($ids) {
        $query->whereIn('role_id', $ids);
    }, '=', count($ids));

Cinek left a reply on Login By Custom Field • 2 months ago

Auth::attempt(['client_id'=>$client_id_from_org])

30th November, 2017

Cinek left a reply on How To Override Email Attribute In User Model • 2 months ago

Can you show all of your ForgotPasswordController.php or sendResetLinkEmail method?

Cinek left a reply on Eloquent Query Filter With Custom Raw Select • 2 months ago

You cannot use select alias in your where clause. There's link to mysql explaination but on postgres or oracle DB will not work too. https://dev.mysql.com/doc/refman/5.7/en/problems-with-alias.html

You have to use YEAR(CURDATE()) - YEAR(birthdate) - IF(STR_TO_DATE(CONCAT(YEAR(CURDATE()), \'-\', MONTH(birthdate), \'-\', DAY(birthdate)) ,\'%Y-%c-%e\') > CURDATE(), 1, 0)

in your where clause.

29th November, 2017

Cinek left a reply on Not Reading Docx Mimes • 2 months ago

Which laravel version? Try:

 'resume' => 'nullable|mimes:docx,doc,zip|max:2000', 

24th November, 2017

Cinek left a reply on N Days Difference In Two Date Fields • 2 months ago

$days = 200;
        $diff = MyData::whereRaw('DATEDIFF(updated_at,created_at) < ?')
            ->setBindings([$days])
            ->get();

Cinek left a reply on N Days Difference In Two Date Fields • 2 months ago

$diff = MyData::select(DB::raw('DATEDIFF(delivery_date,created_at) as days'))->paginate(10);

15th November, 2017

Cinek left a reply on How To Check If Url Contains Parameters And Execute A Action • 3 months ago

You have typo in word "activity".

Better solution than access $_GET directly is

 @if( Request::get('activity') && Request::get('country'))

Cinek left a reply on No Users Found • 3 months ago

Try do this

$trashedAndNotTrashed = User::withTrashed()->get();

If this works then it means your records are deleted using soft delete.

14th November, 2017

Cinek left a reply on Redirect User To Previous URL After Login Into System • 3 months ago

@WeeHong You should have your AuthController in "App\Http\Controllers\Auth". This controller uses AuthenticatesAndRegistersUsers trait, which uses RegistersUsers trait. Simply, you can place redirectPath method in AuthController and it should be overriden.

Cinek left a reply on Redirect User To Previous URL After Login Into System • 3 months ago

You can try to override redirectPath method from RedirectsUsers trait in your auth controller like this:

    {
        return URL::previous();
    }```

6th November, 2017

Cinek left a reply on Polymorphic Relations Images / Articles • 3 months ago

What does it mean "code dosent work"? Are there any errors? Maybe

$request->get('image')

is empty and u need to add enctype = multipart/form-data to your "form" html tag?

Cinek left a reply on How To Get Id Of That Particular Record On Select That Record From Selectbox In Laravel • 3 months ago

U can build selectbox with id as a value: <select name="comic_publisher" id="publishers"> @foreach($group as $team) <option value="{{$team->id}}">{{$team->comic_group_name}}</option> @endforeach </select> and then you can get the selected value in controller $selectedTeam = $request->get('comic_publisher');

12th September, 2017

Cinek left a reply on How To Make A Selected Dropdown Combobox. • 5 months ago

$selectedrole is id of your actual selected element

Cinek left a reply on How To Use Command() In My Controller? • 5 months ago

Why do you want to run scheduler in controller?

11th September, 2017

Cinek left a reply on Model Is Created With Id = 0 • 5 months ago

Try to change

$table->increments('id');

to

$table->increments('id')->unsigned();

Cinek left a reply on Session Database Table Without IP • 5 months ago

I think that you have to extend default session handler and write your own logic to store session in database. You can extend default DatabaseSessionHandler in your own class and override getDefaultPayload function. Then u can register your own session driver like this: AppServiceProvider.php

Session::extend('custom', function($app) use ($connection) {
            $table   = Config::get('session.table');
            $minutes = Config::get('session.lifetime');
            return new CustomSessionStore($connection, $table, $minutes, $app);
        });

and set it in config: session.php

'driver' => 'custom',

8th September, 2017

Cinek left a reply on Laravel Generate Pdf Using Laravel-dompdf • 5 months ago

Second parameter of the loadView method should be an array. Try this:

$pdf = \PDF::loadView('pages.manager.orders.invoice', compact('invoice_order', 
    'invoice_order_details', 'sub_total'));

5th September, 2017

Cinek left a reply on (1/2) ErrorException Undefined Property: Illuminate\Pagination\LengthAwarePaginator::$photos • 5 months ago

Try it:

@foreach($rooms as $room)

@foreach($room->photos as $photo)
  <img src="{{ '/' . $photo->thumbnail_path }}">
@endforeach

@endforeach

Method "paginate" returns paginated collection of rooms. I suppose that photos is a list of photos of each room so you should iterate after all rooms.

30th August, 2017

Cinek left a reply on Laravel-dompdf Thai Language Not Working • 5 months ago

maybe try to download and add custom font to your html like this:

@font-face {
                font-family: arial;
                font-weight: normal;
                src: url("{{base_path()}}/resources/fonts/thai_font.ttf") format("truetype")
            }

29th August, 2017

Cinek left a reply on Getting Data Between Two Dates • 5 months ago

The pluck method returns a collection of object only with "id" property and the "where" function on "date" property shouldn't working because there is no date property. You should to use pluck method after"where" function.

18th August, 2017

Cinek left a reply on Model Is Created With Id = 0 • 6 months ago

Can you show your migration?

9th August, 2017

Cinek left a reply on Translate Raw SQL Into Eloquent • 6 months ago

Try this:

Facility::orderByRaw("substring('product_id' from 1 for 1)")-> > orderBy('name','ASC')->get();

8th August, 2017

4th August, 2017

Cinek left a reply on Authentication • 6 months ago

Change "table" in your config/auth.php from "users" to "my_table".

3rd August, 2017

Cinek left a reply on VerifyCsrfToken.php • 6 months ago

Please read about CSRF protection in laravel https://laravel.com/docs/5.4/csrf

{{ csrf_field() }} ...

31st July, 2017

Cinek left a reply on How To Use That ? • 6 months ago

Cinek left a reply on Problems About Updating A Model Object • 6 months ago

If you do not want to change the column type u can mark column "check_field" as nullable. If you do not specify a value of a "check_field" column while inserting data to database the value will be set to null.

27th July, 2017

Cinek left a reply on How To Use Different Password Column In Default LoginController In Laravel For Login • 6 months ago

You should override getAuthPassword in your User model just like here:

public function getAuthPassword() { return $this->pass; }

and then change the calling method attempt to:

Auth::attempt($credentials)

This should work.

26th July, 2017

Cinek left a reply on How To Use Different Password Column In Default LoginController In Laravel For Login • 6 months ago

Try to change: if (Auth::attempt(['email'=>$email, 'pwd' =>$password])) to: if (Auth::attempt(['email'=>$email, 'password' =>$password]))

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.