Bribin

UX/UI Designer at Bahrain

Experience

3,305

0 Best Reply Awards

  • Member Since 3 Years Ago
  • 26 Lessons Completed
  • 1 Favorite

23rd August, 2018

Bribin started a new conversation Laravel File Upload Different Versions And Formats Of A File • 1 month ago

Let me know a sample. how can I store the uploaded file to the database; laravel ex. In the system, if upload a doc file, it will automatically convert to PDF.(via cloud convert API ). how I can save both files in the database

   ---------------------------------------------------
   |id|proposal_id|version_id|Status|fileName|filetype| 
   ---------------------------------------------------

Bribin left a reply on Help With Has Many Relationships Database Table • 1 month ago

my usage is on upload docx .. automatically docx convert into PDF file & store files. after in show blade. based on proposal ID and Version ID- PDf version. im using cloudconvert Api for Converting PDF,

Bribin left a reply on Help With Has Many Relationships Database Table • 1 month ago

@Yorki Let me know it the proper way of saving doc and pdf of the same version?

or ----------------------------------------------------------------------------------------------------------- | id | proposal_id | version_ID | Status | filetitle | fileNamedoc | fileNamePDF -----------------------------------------------------------------------------------------------------------

Bribin started a new conversation Help With Has Many Relationships Database Table • 1 month ago

I have 2 Tables proposals & Proposal Attachments. each proposal has a docx file & Pdf File. let me know the below table design is correct

proposals ----------------------------------------------------

| id | proposalNo | ProposalTitle | Status | ---------------------------------------------------- | 1 | PRO 123 | sample | 0 | ----------------------------------------------------

proposal_attachments -----------------------------------------------------------------------------------

| id | proposal_id | version_ID | Status | fileName | filetype | ----------------------------------------------------------------------------------- | 1 | 1 | 1 | 1 | Sample1.docx | doctype | ---------- ------------------------------------------------------------------------- | 2 | 1 | 1 | 1 | Sample1.pdf | pdf | ----------------------------------------------------------------------------------- | 3 | 1 | 2 | 1 | Sample1.docx | doctype | ----------------------------------------------------------------------------------- | 4 | 1 | 2 | 1 | Sample1.pdf | pdf | ------------------------------------------------------------------------------------

is this the correct design of Table or Not?

14th January, 2018

Bribin left a reply on Laravel Invoice And Invoice Items - Foreach Hasmany Relationship • 9 months ago

@Snapey that time. If I remove a exitising item from the form?

Bribin left a reply on Laravel Invoice And Invoice Items - Foreach Hasmany Relationship • 9 months ago

@VijayKadiyam both if already is thre update. otherwise create

Bribin started a new conversation Laravel Invoice And Invoice Items - Foreach Hasmany Relationship • 9 months ago

i have 2 tables . if update or create method

proposal
        id
        pro_amt
--------------------------------
invoice_items
        proposal_id
        item
        price

i can successfully save date. i have some problems with updating data

Save method

foreach ($request->proposalItems as $item)
{
$data = array(
'proposal_id' => $proposal->id,
'item' => $item['item'],
'price' => $item['price'],
);
$proposal->ProposalItems()->create($data);
}

Update Method

  $items =$request->proposalItems;
        foreach ($items as $item) {
            $data = array(
                'proposal_id' => $proposal->id,
                'item' => $item['item'],
               
                'price' => $item['price'],
            );
         $proposal->ProposalItems()->updateorcreate($data);
     }

my form

 @if (!empty($proposals->ProposalItems))
                                    <?php $count = 0; ?>
                                    @foreach ($proposals->ProposalItems as $item )
                                        <tr class="item-row">
                                            <td> <input type="hidden" name="proposalItems[<?php echo $count; ?>][item_id]" value="{{$item->id}}"> {!! Form::text('proposalItems['.$count.'][title]',$item->item, ['class' => 'form-control','required'=>'required'] ) !!}</td>
                                          
                                            <td>{!! Form::number('proposalItems['.$count.'][price]',$item->price, ['class' => 'form-control price','data-parsley-type'=>'number','required'=>'required'] ) !!}</td>
                                            @if ($count > 0)
                                                <td><button id="<?php echo $count; ?>" type="button" class="btn btn-danger delRow"><i class="fa fa-trash-o" aria-hidden="true"></i></button></td>
                                            @else
                                                <td><button id="addRow" type="button" class="btn btn-default"><i class="fa fa-plus" aria-hidden="true"></i></button></td>
                                            @endif
                                        </tr>
                                        <?php $count++ ?>
                                    @endforeach
                                @else
                                    <tr class="item-row">
                                        <td><input type="hidden" name="item_id[]" value=""> {!! Form::text('proposalItems[0][title]',NULL, ['class' => 'form-control','required'=>'required'] ) !!}</td>
                             
                                        <td>{!! Form::number('proposalItems[0][price]',NULL, ['class' => 'form-control price','data-parsley-type'=>'number','required'=>'required'] ) !!}</td>
                                        <td>
                                            <button id="addRow" type="button" class="btn btn-default"><i class="fa fa-plus" aria-hidden="true"></i></button>
                                        </td>
                                    </tr>
                                @endif

````


12th January, 2018

Bribin left a reply on Check If The Object Request Is Empty Before For Each • 9 months ago

It's not a single key.its a request array having 3 fields

10th January, 2018

Bribin left a reply on Check If The Object Request Is Empty Before For Each • 9 months ago

All of them is null

Bribin left a reply on Check If The Object Request Is Empty Before For Each • 9 months ago

i tried this. its not working with my needs.

$contacts = collect($request->contacts);

Output is

[{"first_name":null,"last_name":null,"contact_email":null,"contact_phone":null,"contact_department":null}]

if the output values is null i dnt want to save the values. otherwise save the values

Bribin left a reply on Check If The Object Request Is Empty Before For Each • 9 months ago

I want to insert the data into database not displaying

Bribin started a new conversation Check If The Object Request Is Empty Before For Each • 9 months ago

  <tr >
                                    <td> {!! Form::text('contacts[][first_name]',NULL, ['class' => 'form-control'] ) !!}</td>
                                    <td> {!! Form::text('contacts[][last_name]',NULL, ['class' => 'form-control'] ) !!}</td>
                                    <td> {!! Form::text('contacts[][contact_email]',NULL, ['class' => 'form-control'] ) !!}</td>
                                    <td> {!! Form::text('contacts[][contact_phone]',NULL, ['class' => 'form-control'] ) !!}</td>
                                    <td> {!! Form::text('contacts[][contact_department]',NULL, ['class' => 'form-control'] ) !!}</td>
                                </tr>

check if the Object request is empty before foreach, without form validation


if(empty($request->contacts))
{
 do something
}

8th January, 2018

Bribin started a new conversation Checking If A Request Array Is NULL In Laravel • 9 months ago

I have a dynamically generated form that gives me an array of inputs. However the array might be empty, then the foreach will fail.

if(null($request->contacts)) { #do something }

how to check if there is any no input in array

27th September, 2015

Bribin started a new conversation Dropzone Js + File Upload File Order • 3 years ago

Hi, Im developing a project with Dropzone file upload, i want to pass the order of dropone file into data base , how i can save the order/position of the file in database

    $file = Input::file('file');
        $campaign =  Campaign::getCampaign($id);
           
        $uploadPath = 'uploads/stores/'.$campaign->store->id.'/'.$id.'/';
        $destinationPath = '/uploads/stores/'.$campaign->store->id.'/'.$id.'/';
        $filename = $id .'-'.$campaign->store->id.$file->getClientOriginalName();
        $upload_success = Input::file('file')->move($uploadPath, $filename);

            if ($upload_success) {
                    // resizing an uploaded file
                $thumb = Image::make($uploadPath.$filename)->resize(184, NULL,  function ($c) {
                    $c->aspectRatio();
                    $c->upsize();
                });
                $thumb->save($uploadPath.'thumb_'.$filename);
            }

        $campaign->flyers()->create(
                 ['path' => $destinationPath.$filename, 'order'=> $i ,'thumbnail'=>    $destinationPath.'thumb_'.$filename]
        );
    return  'success';

dropzone .js config

Dropzone.options.addflyer = { uploadMultiple: false, parallelUploads: 1, maxFilesize: 8, autoProcessQueue: false, addRemoveLinks: true, dictRemoveFile: 'Remove', dictFileTooBig: 'Image is bigger than 8MB',

         };

24th September, 2015

Bribin started a new conversation Project Flyer - File Name As Flyerid Counter & File Count • 3 years ago

Hi,

I'm trying to implement Project flyer , How i can get the uploaded photos nameing like example [flyerID].[photo-1.png] [flyerID].[photo-2.png] [flyerID].[photo-3.png]

    $file = Input::file('file');
        $file_count = count($file);
        $destinationPath = public_path() . '/uploads/stores/' ;
        $filename = time() . $file->getClientOriginalName();
        $upload_success = Input::file('file')->move($destinationPath, $filename);
        $campaign =  Campaign::where(compact($id))->first();
        $campaign->flyers()->create(
            ['path' => $destinationPath]
             );

18th September, 2015

Bribin left a reply on DropzoneJs Files Save Order As Filename To Database Laravel 5 • 3 years ago

I have flyers and photos. Each flyer contains many photos.

namespace App;

use Image; use Illuminate\Database\Eloquent\Model; use Symfony\Component\HttpFoundation\File\UploadedFile;

class Photo extends Model {

/**
 * Database table
 *
 * @var string
 */
protected $table = 'flyer_photos';

/**
 * Fillable fields
 *
 * @var array
 */
protected $fillable = [
    'path',
    'name',
    'thumbnail_path'
];

/**
 * Base path to images
 *
 * @var string
 */
protected $baseDir = 'images/home_pics';


/**
 * Get instance from form
 *
 * @param $name
 * @return static
 * @internal param UploadedFile $file
 */
public static function named($name)
{

    return (new static)->saveAs($name);

}

/**
 * Set values to this
 *
 * @param $name
 * @return $this
 */
public function saveAs($name)
{

    $this->name = sprintf("%s-%s", time(), $name);
    $this->path =sprintf("%s/%s", $this->baseDir, $this->name);
    $this->thumbnail_path = sprintf("%s/tn-%s", $this->baseDir, $this->name);

    return $this;

}

/**
 * Move photo
 *
 * @param UploadedFile $file
 * @return $this
 */
public function move(UploadedFile $file)
{

    $file->move($this->baseDir, $this->name);

   $this->makeThumbnail();

    return $this;

}

/**
 * Generate thumbnail
 *
 */
private function makeThumbnail()
{

    Image::make($this->path)
        ->fit(200)
        ->save($this->thumbnail_path);
}


/**
 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
 */
public function flyers()
{

    return $this->belongsTo('App\Flyer');

}

}

Bribin left a reply on DropzoneJs Files Save Order As Filename To Database Laravel 5 • 3 years ago

@sid405 yes. I want to Upload multiple images in the same order. and after uploading also i want to sort the order

Bribin started a new conversation DropzoneJs Files Save Order As Filename To Database Laravel 5 • 3 years ago

I am working on a project which involves file uploading. I am using DropzoneJS and Laravel for this project. Everything seems to work fine, i want to save files with order.i want to pass the image order and save image file in that order.

var baseUrl = "{{ url('/') }}"; var token = "{{ Session::getToken() }}";

Dropzone.autoDiscover = false;
var myDropzone = new Dropzone(".dropzone", {
    url: baseUrl + "/upload",
    params: {
        _token: token

    }
});
Dropzone.options.myAwesomeDropzone = {
    paramName: "flyers",
    acceptedFiles: "image/*",
    enqueueForUpload: true,
    forceFallback: false,
    dictDefaultMessage: "Drop files here to upload",
    autoProcessQueue: false,
    uploadMultiple: false,
    maxFilesize: 2, // MB
    addRemoveLinks: true,

    accept: function(file, done) {

    },
};
    

public function album() { $file = Input::file('file');

$destinationPath = 'uploads'; $filename = $file->getClientOriginalName();

$uploadSuccsess = Input::file('file')->move($destinationPath, $filename); if( $uploadSuccsess ) { return Response::json('success', 200); } else { return Response::json('error', 400); } }

25th May, 2015

Bribin left a reply on Add Database Record And Redirect To Edit View With New Record ID • 3 years ago

@christophrumpel only empty rows with primary key. I want only primary Key. two Rows adding in each request

Bribin left a reply on Add Database Record And Redirect To Edit View With New Record ID • 3 years ago

Thanks @christophrumpel

    public function create()
    {
    $page = new Page;
    $page->save();
    return Redirect::to("/dashboard/pages/" . $page->id . "/edit");
    }

its working Properly but its adding two rows to database :(

Bribin started a new conversation Add Database Record And Redirect To Edit View With New Record ID • 3 years ago

How to Add Database Record and Redirect to Edit View with New Record ID in Create Route in resource controller ?

20th March, 2015

Bribin started a new conversation Requests Does Not Exit • 3 years ago

ReflectionException in RouteDependencyResolverTrait.php line 53: Class App\Http\Controllers\PageRequests does not exist

use App\Page; use App\Http\Requests\PageRequest; use App\Http\Requests; use Illuminate\Http\Request;

class PageController extends Controller {

17th March, 2015

Bribin left a reply on Generate A Unique Slug From Title • 3 years ago

@sitesense Thanks for Replay .. This also i tried . again im getting the same Error :(

Bribin left a reply on Generate A Unique Slug From Title • 3 years ago

@sitesense

I Tried this method. but im getting this Error

FatalErrorException in PageController.php line 63: Class 'Str' not found

Bribin started a new conversation Generate A Unique Slug From Title • 3 years ago

Please help me to generate a Unique Slug From Title

10th March, 2015

Bribin started a new conversation Changing Middleeware Auth Routes • 3 years ago

How to change the middle ware auth route

domainname.com/auth/logii to domainname.com/auth/signin

Edit Your Profile
Update

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